Jump to content

posting date/time of form usage to mysql db?


paulmo

Recommended Posts

yikes! (was writing reply while previous posted. that NOW function seems so easy. how does it know what table to go to?) i need to post date/time in same table row as the following when the form's submitted:

mysql_connect("xxx", "xxx", "xxx") or die(mysql_error()); 
mysql_select_db("xxx") or die(mysql_error()); 
$name = mysql_real_escape_string($_POST['name']);
$theme = mysql_real_escape_string($_POST['theme']);

mysql_query("INSERT INTO interactive (name, theme) VALUES ('$name', '$theme') ") or die(mysql_error());

 

i'm reading about date (format, [timestamp]); but unsure how to start.

 

would "created" in example above be the date/time field in table?

 

thank you!!

Something like this?

 

mysql_connect("xxx", "xxx", "xxx") or die(mysql_error());
mysql_select_db("xxx") or die(mysql_error());
$name = mysql_real_escape_string($_POST['name']);
$theme = mysql_real_escape_string($_POST['theme']);

mysql_query("INSERT INTO interactive (name, theme, created) VALUES ('$name', '$theme', NOW()) ") or die(mysql_error());

you're the greatest! so simple. seems that php, mysql, js, all can do similar things, but this one has to win for simplicity. i'm guessing it's all gleaned from the mysql manual? i'm referring to that, but defintions can seem cryptic to a noob without knowing the applications.

 

thanks again!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.