Drop dow list for date only inserts year into database

Hi i have a drop dwon menu for date which is meant to insert all 3 values into a date column bt is only sending the year hwo can i fix it

<select name="date_of_birth">
    <option value="1">January
    <option value="2">February
    <option value="3">March
    <option value="4">April
    <option value="5">May
    <option value="6">June
    <option value="7">July
    <option value="8">August
    <option value="9">September
    <option value="10">October
    <option value="11">November
    <option value="12">December
</select>
<select name="date_of_birth">
    <option value="1">1
    <option value="2">2
    <option value="3">3
    <option value="4">4
    <option value="5">5
    <option value="6">6
    <option value="7">7
    <option value="8">8
    <option value="9">9
    <option value="10">10
    <option value="11">11
    <option value="12">12
    <option value="13">13
    <option value="14">14
    <option value="15">15
    <option value="16">16
    <option value="17">17
    <option value="18">18
    <option value="19">19
    <option value="20">20
    <option value="21">21
    <option value="22">22
    <option value="23">23
    <option value="24">24
    <option value="25">25
    <option value="26">26
    <option value="27">27
    <option value="28">28
    <option value="29">29
    <option value="30">30
    <option value="31">31
</select>
<select name="date_of_birth" id="year">
<?php
$year = date("Y");
for($i=$year;$i>$year-50;$i--)
{
if($year == $i)
echo "<option value='$i' selected>Current Year</option>";
else
echo "<option value='$i'>$i</option>";
}
?>

Normally that would be a good solution, but IMO it’s not really the best tool to select a birthday, since people would have to scroll back at least a few years…

One possible solution if your sure the majority of users won’t block javascript would be a javascript date selector.

That is one that I found via a quick google search

The ones I posted in #4

Where are the dashes ??

which dashes ???

this how i modified bt now it doesnt post the date


$date_of_birth = $_POST['year_of_birth'] . ' ' . $_POST['month_of_birth'] . ' ' . $_POST['day_of_birth'];
$q = "INSERT INTO driversnew (id, name, location, date_of_birth, car_number,
   favourite_track, least_favourite_track, achievements, sponsors, email, image, display)
VALUES ('$_POST[id]', '$_POST[name]', '$_POST[location]','$date_of_birth','$_POST[car_number]','$_POST[favourite_track]', '$_POST[least_favourite_track]','$_POST[achievements]', '$_POST[sponsors]','$_POST[email]', '$image_name','0')";
$rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error());

u mean here still dioesnt wrk??

$date_of_birth = $_POST[‘year_of_birth’] . ‘-’ . $_POST[‘month_of_birth’] . ‘-’ . $_POST[‘day_of_birth’];

Its because all 3 of your select boxes have the name of “date_of_birth”, they all need unique names in order to be sent from a form

does that mean i have to create 3 more columns into the database one 4 month one 4 year and one for day???

either i am doing it wrong cz that didnt wrk??
this my insert query i named them birth yer and month but now only inserting the month into the database hwo will that insert 3 of them into 1 column??

mysql_query("INSERT INTO driversnew (id, name, location, date_of_birth, car_number,
   favourite_track, least_favourite_track, achievements, sponsors, email, image, display)
VALUES ('$_POST[id]', '$_POST[name]', '$_POST[location]','$_POST[date_of_birth]','$_POST[date_of_month]','$_POST[date_of_year]','$_POST[car_number]','$_POST[favourite_track]', '$_POST[least_favourite_track]','$_POST[achievements]', '$_POST[sponsors]','$_POST[email]', '$image_name','0')");
}

No it just means you need to split the values when they leave the database, like ScallioXTX said add the values to the database as one value like he posted…

INSERT INTO table VALUES ('".$_POST['date_of_birth_year']."-".$_POST['date_of_birth_month']."-".$_POST['date_of_birth_day."')

Then when you retrieve them (if you need to) use

$ymd = preg_split('/-/', $database_value_here);
echo $ymd[0].'<br />'.$ymd[1].'<br />'.$ymd[2];

How about calling them date_of_birth_day, date_of_birth_month and date_of_birth_year and then insert $_POST[‘date_of_birth_year’].‘-’.$_POST[‘date_of_birth_month’].‘-’.$_POST[‘date_of_birth_day’] in the database?

Try echoing the query before you execute it to see if something’s wrong there. Also take a look at [fphp]mysql_real_escape_string[/fphp] to prevent SQL Injection as the code you’re currently showing is wide open to security attacks!

this how evrything looking


$date_of_birth = $_POST['year_of_birth'] . '-' . $_POST['month_of_birth'] . '-' . $_POST['day_of_birth'];
$q = "INSERT INTO driversnew (id, name, location, date_of_birth, car_number,
   favourite_track, least_favourite_track, achievements, sponsors, email, image, display)
VALUES ('$_POST[id]', '$_POST[name]', '$_POST[location]','$date_of_birth','$_POST[car_number]','$_POST[favourite_track]', '$_POST[least_favourite_track]','$_POST[achievements]', '$_POST[sponsors]','$_POST[email]', '$image_name','0')";
$rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error());

and the form

<?php
$months = array('','January','February','March','April','May','June','July','August','September','October','November','December');
echo '<select name="month_of_birth">';
for ($i=1;$i<13;++$i) {
   echo '<option value="' . sprintf("%02d",$i) . '">' . $months[$i] . '</option>';
}
echo '</select>';
echo '<select name="day_of_birth">';
for ($i=1;$i<32;++$i) {
   echo '<option value="' . sprintf("%02d",$i) . '">' . $i . '</option>';
}
echo '</select>';
echo '<select name="year_of_birth">';
$year = date("Y");
for ($i = $year;$i > $year-50;$i--) {
   $s = ($i == $year)?' selected':'';
   echo '<option value="' . $i . '" ' . $s . '>' . $i . '</option>';
}
echo '</select>';
?>

like this??
$date_of_birth = $_POST[‘year_of_birth’] . ‘-’ . $_POST[‘month_of_birth’] . ‘-’ . $_POST[‘day_of_birth’];

yeah but then how do i sent into column because i have like this

mysql insert ‘$_POST[date_of_birth]’ do i change that to what if all three will have different names???