English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

My form is:


Firstname:
Lastname:
Age:



insert.php file:
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("my_db", $con);

$sql="INSERT INTO person (FirstName, LastName, Age)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";

if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";

mysql_close($con)
?>


How do I add in timestamp(yyyymmddhhmmss) into the form and file so it is stored in my database?

Thanks

2007-08-20 11:28:48 · 1 answers · asked by S J 1 in Computers & Internet Programming & Design

1 answers

You should pull it from your own server as a internal variable. Consult MySQL for "time" as environment variable or a date/time function. You don't want client's "local" time any way. It'd be impossible to sort properly. Better use your own server time.

2007-08-20 11:37:51 · answer #1 · answered by Kasey C 7 · 2 0

fedest.com, questions and answers