Menu selection if validation fails
When validation fails, my text fields remain filled with this code.
<input id="HomeName" name="HomeName" type="text" value="<?php echo((isset($_GET["invalid"])?ValidatedField("residenceinsert","HomeName"):"")); ?>" class="formTextfield_Medium" tabindex="6" title="Please enter a value.">
<?php
if (ValidatedField('residenceinsert','residenceinsert')) {
if ((strpos((",".ValidatedField("residenceinsert","residenceinsert").","), "," . "5" . ",") !== false || "5" == "")) {
if (!(false)) {
?>
My dropdown menu selections however return to the default. Between the default value and the dynamic values I am not sure how to get the drop down to return to the entered value as with the text field.
<select name="agent" id="agent">
<option value="None" <?php if (!(strcmp("None", ((isset($_POST["agent"]))?$_POST["agent"]:"")))) {echo "selected=\"selected\"";} ?>>None</option>
<?php
do {
?>
<option value="<?php echo $row_agents['Agent']?>"<?php if (!(strcmp($row_agents['Agent'], ((isset($_POST["agent"]))?$_POST["agent"]:"")))) {echo "selected=\"selected\"";} ?>><?php echo $row_agents['Agent']?></option>
<?php
} while ($row_agents = mysql_fetch_assoc($agents));
$rows = mysql_num_rows($agents);
if($rows > 0) {
mysql_data_seek($agents, 0);
$row_agents = mysql_fetch_assoc($agents);
}
?>
</select>
<?php
if (ValidatedField('residenceinsert','residenceinsert')) {
if ((strpos((",".ValidatedField("residenceinsert","residenceinsert").","), "," . "3" . ",") !== false || "3" == "")) {
if (!(false)) {
?>
<span class="serverInvalidState">Field is Mandatory </span>
<?php //WAFV_Conditional residence_insert.php residenceinsert(3:)
}
}
}?>