Hi
I get the user to enter their date of birth by selecting the day, month and year from generated drop-down boxes.
I then want to put this into the database as either DD-MM-YYYY or the default YYYY-MM-DD but each time it just enters: 0000-00-00.
What am I doing wrong with the following code:
<!-- DAY -->
<TD><SELECT NAME="day" class="formselect" />
<OPTION SELECTED VALUE="">Select</OPTION>
<?php
for ($day = 1; $day <= 31; $day++) {
if ($day<10) {
$day = "0".$day;
}
echo "<option value=\"".$day."\">".$day."</option>\n";
}
?>
</SELECT>
<!-- MONTH -->
<SELECT NAME="month" class="formselect" />
<OPTION SELECTED VALUE="">Select</OPTION>
<?php
$today = getdate();
$thismonth = 1;
for ($x=$thismonth;$x<13;$x++) {
echo "<option value=\"".date("m", mktime(0,0,0,$x,1,0))."\">".date("F", mktime(0,0,0,$x,1,0))."</option>\n";
}
?>
</SELECT>
<!-- YEAR -->
<SELECT NAME="year" class="formselect" alt="select" />
<OPTION SELECTED VALUE="">Select</OPTION>
<?php
$todayyear = $today['year'];
for ($year = 1927; $year <= $todayyear-18; $year++) {
echo "<option value=\"".$year."\">".$year."</option>\n";
}
?>
</SELECT>
<?php
$day = $_POST["day"];
$month = $_POST["month"];
$year = $_POST["year"];
$DOB = $_POST["year"] . $_POST["month"] . $_POST["day"];
$mDOB = date('Ymd', $DOB);
?>
To test I try and echo $DOB or mDOB but nothing is displayed. However, if I echo the individual day, month or year, those are outputted.
Any ideas on what I am doing wrong?
Help!!
Thanks.
Mak