如何在mysql中插入日期

So far i have created drop downs for year,month and day. I have used php to insert the data in mysql database but it does not work, the dates are not inserting into the database, it is really annoying as i don't know what the problem is. Would love some help please. thanks

form code

<form method=post name=f1 action=''><input type=hidden name=todo value=submit>
<table border="0" cellspacing="0" >
<tr><td align=left >
<select name=month value=''>Select Month
<option value='01'>January</option>
<option value='02'>February</option>
<option value='03'>March</option> etc.. 

I have done the same for day and year.

php code

require("common.php"); 
<?php
$todo=htmlentities($_POST['todo']);
if(isset($todo) and $todo=="submit"){
$month=htmlentities($_POST['month']);
$dt=htmlentities($_POST['dt']);
$year=htmlentities($_POST['year']);
$date_value="$month/$dt/$year";
echo "mm/dd/yyyy format :$date_value<br>";
$date_value="$year-$month-$dt";
echo "YYYY-mm-dd format :$date_value<br>";
}

$m=$month;
$d=$dt;
$y=$year;
If(!checkdate($m,$d,$y)){
echo "invalid date";
}else {
echo "Entry date is correct";
}
$sql="INSERT INTO survey (dates)
VALUES
('$_POST[$date_value])"; 

     mysql_query($sql);


      exit();  

?>

Correct your insert query:

$sql="INSERT INTO survey (dates) VALUES ('$date_value')"; 

Use this just concat the date like below

$month=htmlentities($_POST['month']);
$dt=htmlentities($_POST['dt']);
$year=htmlentities($_POST['year']);
$date_value=$year.'-'.$month.'-'.$dt;

$sql="INSERT INTO survey (dates) VALUES ('".$date_value."')"; 
<?php
$dbhost = 'localhost:3036';
$dbuser = 'root';
$dbpass = 'rootpassword';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
  die('Could not connect: ' . mysql_error());
}
$sql = 'INSERT INTO employee '.
       '(emp_name,emp_address, emp_salary, join_date) '.
       'VALUES ( "guest", "XYZ", 2000, NOW() )';

mysql_select_db('test_db');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not enter data: ' . mysql_error());
}
echo "Entered data successfully
";
mysql_close($conn);
?>

this may help you out..

$_POST[$date_value] is not a part of $_POST !!!

$date_value="$year-$month-$dt";

so replace your $_POST[$date_value] in the INSERT quert with $date_value

like this

$sql="INSERT INTO survey (dates) VALUES ('".$date_value."')";