Hi, I am building a blog. Everything is working great except the timestamp field (for user's comments) in my blog_comments table. It doesn't recieve any values and stays at "0".
I have checked and checked and checked and... well, you get the idea. Can someone look at my code?
Here is the code on my blog page (I call it details.php). It contains the form that users can use to make comments on.
<?php
// Grab current time/date info from server
$current_month = date("F");
$current_date = date("d");
$current_year = date("Y");
$current_time = date("H:i");
?>
<form method='post' action='details_action.php'>
<fieldset>
<legend>» Add Your Comments</legend>
<input type='hidden' name='entry' value='<?php echo "$id"; ?>'>
<input type='hidden' name='timestamp' value='<?php echo"$current_month" . "$current_date" . "$current_year" . "$current_time"; ?>'> <?php //THIS is the field in question ?>
<input type='text' name='name' size='25' value=''>
<label>Name</label>
<br>
<input type='text' name='email'>
<label>Email</label>
<br>
<input type='text' name='url' value='http://'>
<label>URL</label>
<br>
<textarea name='comment'></textarea>
<label>Comment</label>
<br>
<input type='submit' name='submit_comment' value='Comment'>
</fieldset>
</form>
The value in the timestamp field is working. I have tested by changing the type from "hidden" to "text", and sure enough, the server time/date info is there...
Here is the code on my action page:
<?php
$entry = $_POST['entry'];
$timestamp = $_POST['timestamp']; // THIS IS THE BUGGER!! ??
$name= $_POST['name'];
$email = $_POST['email'];
$url = $_POST['url'];
$comment = $_POST['comment'];
$comment = strip_tags($comment);
$comment = nl2br($comment);
$continue = 1;
if ($name == "" || $comment == "")
{
echo "<p>(error message)</p>";
$continue = 0;
}
elseif ($name != "" && $comment != "")
{
$continue = 1;
}
if ($continue == 1)
{
require ("../inc/db.inc.php"); // db conn info
$my_db = connecting2_db(); // "connecting2_db()" function on db.inc.php
$sql = "INSERT INTO blog_comments (entry, name, email, url, comment, timestamp) VALUES ('$entry', '$name', '$email', '$url', '$comment', '$timestamp')"; // TIMESTAMP BUGGER!!??
$result = mysql_query($sql,$my_db) or print ("Can't add comments to table blog_comments." . $sql . mysql_error());
echo "Your Comments have been saved @ $timestamp\n
<meta HTTP-EQUIV='REFRESH' CONTENT='5; URL=details.php?id=$entry'>\n";
}
?>
Any help would be greatly appreciated...