A
Anonymous
Guest
Hello I am creating a user registration form and I have a section where they state their date of birth. I am trying to make it so that if there is an error somewhere in the form that the values in the select option do not reset to their default.
This is the code I have tried, I hope you can see what it is that I am trying to acheive. I have left out unessecary parts of the code such as table structure and the entire options list.
This is the code I have tried, I hope you can see what it is that I am trying to acheive. I have left out unessecary parts of the code such as table structure and the entire options list.
Code:
<select name="day" value="<?php if($_POST['day']!="00"){echo $_POST['day'];}?>">
<option value ="00">Day</option>
<option value ="01">1</option>
<option value ="02">2</option>
<option value ="03">3</option>
</select>
<select name="month" value="<?php if($_POST['month']!="00"){echo $_POST['month'];}?>">
<option value ="00">Month</option>
<option value ="01">January</option>
<option value ="02">February</option>
</select>
<select name="year" value="<?php if($_POST['year']!="00"){echo $_POST['year'];}?>">
<option value ="00">Year</option>
<option value ="1950">1950</option>
<option value ="1951">1951</option>
<option value ="1952">1952</option>
</select>