I'm trying to submit the current date/time to a DATETIME field in an SQL database alongside some text. The text gets entered fine but the date doesn't get submitted at all. Anyone know where I'm going wrong?
The format of the DATETIME field is 2001-10-27 14:39:49
What I have so far is...
PHP Code:
<?
if (isset($_POST['add'])) {
$text = htmlspecialchars($_POST['text']);
$date = htmlspecialchars($_POST['date']);
if ($text != "") {
$query = "INSERT INTO table1 (text, date) VALUES ('$text', '$date')";
@mysql_query($query);
echo "</center>Sucessfully added the following:<p />
$text";}
else { echo "Error. All fields must be filled."; }}
?>
<form enctype="multipart/form-data" method="post" action="<?php $_SERVER['PHP_SELF']?>">
<input type="hidden" name="date" value="<?php (date("Y/m/d, h:s A")); ?>">
<table>
<tr>
<td>
Text: <textarea rows="7" cols="30" name="text"></textarea>
</td>
</tr>
<tr>
<td>
<input type="submit" name="add" value="Add Entry"></td>
</tr>
</table>
</form>
Social Networking Bookmarks