I need help with form validation. I can get it to work with text boxes but I am having trouble validating drop down lists.
I have included a part of my php code plus the code that is imbedded in the HTML
I am having trouble displaying the required text next to the drop down list. Also how would I display the user selected option if the user forgets to enter an input elsewhere on the form so it doesn't reset the dropdown field and show what the user had already had selected.
<?php
if(empty($_POST['title']))
{
$errors['title1'] = " Required";
}
<p>
?>
<label for="title" class="label"><font color="#040404">Title:</font></label>
<select name="title">
<option value="" selected="selected">Select title</option>
<option value ="Mr">Mr</option>
<option value ="Mrs">Mrs</option>
<option value="Ms">Ms</option>
<option value="Miss">Miss</option>
<option value="Dr">Dr</option>
</select>
</p>
$_SESSIONand store a value. When the user submits the form, then update the value of the particular session variable. Then when the page loads, you can use PHP to check if the session variable has been set, and (if so) use that value as the selected option of the dropdown. - Adam T