I am able to retrieve the date of birth from the database and populate it in a option tag after the user has entered the date of birth. However, if the user updates anything else in the form the option value starts updating the database with the wrong date of birth. It seems that it's counting backwards for some reason. How to do I resolve this matter?
if($_POST){
$dob = date('Y-m-d',strtotime($_POST['year']."-". $_POST['month']."-".$_POST['day']));
$retur = $userObj->updateProfile($dob);
}
public function updateProfile($dob){
$db = db_mysql::getInstance();
$qr = $db->query("UPDATE ".USERS." SET dob = $dob WHERE id = '".$udata."'") or die(mysql_error());
return $udata;
}
<label>Date of Birth:</label>
<select style="background-color: #D6CFD4;" name="month">
<option value="{date('F',strtotime($udata.dob))}">{date('F',strtotime($udata.dob))}</option>
<option value="01">January</option>
<option value="02">Febuary</option>
<select style="background-color: #D6CFD4;" name="day">
<option value="{date('d',strtotime($udata.dob))}">{date('d',strtotime($udata.dob))}</option>
<option value="01">01</option>
<option value="02">02</option>
<select style="background-color: #D6CFD4;" name="year">
<option value="{date('Y',strtotime($udata.dob))}">{date('Y',strtotime($udata.dob))}</option>
<option value="2012">2012</option>
<option value="2011">2011</option>