The website form that I need help on requires users to fill out certain fields and if those fields are not filled out the form resets with text requesting the user to populate the fields.
The problem I am having is that all drop down values are resetting when my form displays the error message. However text fields that users manually fill in data do not reset.
I am using <select> and <option> tags for my drop down menus and <input> tags for my fields.
How can I keep the drop down values from resetting? Do I need to change the way I display the error message?
Click here for the website form in question.
Here is the code for the required fields.
if ($_POST && !$_POST['drvset']) {
//var_dump($_POST);
$required = array ("name","byear","bmonth","bday","propertyaddress","zip","email1","email2","homephone");
foreach ($required as $key => $value) {
if ($_POST[$value] == '') {
$err = 1;
}
if (($value == 'byear' && $_POST['byear'] == '0')||($value == 'bmonth' && $_POST['bmonth'] == '0')||($value == 'bday' && $_POST['bday'] == '0')) {
$err = 1;
}
if ($err == '' && $_POST['email1'] != $_POST['email2']) {
$err = 2;
}
}