Hi!
I need to take the info from these pulldowns and format that into a date that can be put into a MYSQL database. I've tried the DATA_FORMAT tag when inserting and a bunch of other things but the date never gets entered into the DB. I either get the default date that I set in the DB or I get all 0s. If someone could look at my code and give me a clue as to how I might do this, that would be great. Thanks ahead of time!
if(!checkdate($POST['month'], $POST['day'], $POST['year'])) {
echo 'Invalid date entered...';
} else {
$datereceived = $POST['month']. $POST['day']. $POST['year'];
$query = "INSERT INTO bands ( bands, day )
values( '$bands', '$datereceived' )";
}
if ( ! mysql_query( $query, $link ) ) {
$dberror = mysql_error();
return false;
}
return true;
}
?>
<html>
<head>
<title>insert</title>
</head>
<body>
<form method="post">
<select name="month">
<?php
$months = Array("January", "February", "March", "April", "May", "June", "July", "August",
"September", "October", "November", "December");
for ( $x=1; $x <= count( $months ); $x++ ) {
print "\t<option value=\"$x\"";
print ( $x == $month)?" SELECTED":"";
print ">".$months[$x-1]."\n";
}
?>
</select>
<select name="day">
<?php
for ( $x=1; $x<31; $x++ ) {
print "\t<option value=\"$x\"";
print ( $x == $day)?" SELECTED":"";
print ">$x\n";
}
?>
</select>
<select name="year">
<?php
for ( $x=2003; $x<2010; $x++ ) {
print "\t<option value=\"$x\"";
print ( $x == $year)?" SELECTED":"";
print ">$x\n";
}
?>
</select>
<p>
BANDS<br>
<textarea name="bands" rows="5" cols="50"></textarea>
</p>
<input type="submit" value="GO">
</form>