Hi every on.I new in php.I m trying to insert date from 3 dropdwon to my date table.It is working well but in table the date is showing always 00-00-0000.plz any one give me a solution.My scripts are followings:
//table
-- Table structure for table `date`
--
CREATE TABLE IF NOT EXISTS `date` (
`id` int(5) NOT NULL auto_increment,
`date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=11 ;
//HTML
<form method="post" action="insert.php">
<select name="Birthday_month" id="Birthday_month">
<option value="-1">Month:</option>
<option value="1">Jan</option>
<option value="2">Feb</option>
<option value="3">Mar</option>
</select><select name="Birthday_day" id="Birthday_day">
<option value="-1">Day:</option><option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<select name="birthday_year" id="birthday_year">
<option value="-1">Year:</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
<option value="2007">2007</option>
</select>
<input type="submit" name="Signup" value="Sign_Up">
</form>
//insert.php
<?php
include('config.php');
if (isset($_POST['Signup']))
{
$timestamp=strtotime($_POST['Birthday_month'].$_POST['Birthday_day'].$_POST['birthday_year']);
$date=date('M-d-Y',$timestamp);
$query="insert into date values('','$date')";
$res=mysql_query($query)or die(mysql_error());
echo mysql_affected_rows();
}
?>
//config.php
<?php
$server='localhost';
$user='root';
$password='';
$database='test';
$link=mysql_connect($server,$user,$password);
if(!$link)
{
die ("Failed to Connect".mysql_error());
}
$db_select=mysql_select_db($database,$link);
if(!$db_select)
{
die("failed select database".mysql_error());
}
?>
//table after insert
id date
1 0000-00-00 00:00:00
2 0000-00-00 00:00:00
3 0000-00-00 00:00:00
4 0000-00-00 00:00:00
5 0000-00-00 00:00:00
6 0000-00-00 00:00:00