PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?
if (isset($_POST['submit']))
{
$message = NULL;
if (empty($_POST['month']) || empty($_POST['day']) || empty($_POST['year']))
{
$sd = false;
$message .= 'no date<br>';
}
else
{
$sd = $_POST['month']."-".$_POST['day']."-".$_POST['year'];
}
if ($sd)
{
$query = "INSERT INTO sample(startdate) VALUES ('$sd')";
$result = @mysql_query($query) or die(mysql_error());
if ($result)
{
echo 'written to db';
exit();
}
else
{
$message .= 'no data written in the db';
}
mysql_close();
}
else
{
$message .= 'please try again';
}
}
if (isset($message))
{
echo '<font color=red>'.$message.'</font>';
}
?>
<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post">
<? calendar(); ?>
<input type="submit" name="submit" value="submit" />
</form>
the code above works and is written to mysql as varchar...but changing the startdate properties to date will not write the right value of the form to mysql...i tried to click the submit button with the desired date, will prompt me that the process is successful...but the value written to my database is 0000-00-00 and not the date i supplied