Jump to content

Automaticly adding a date


danposs86

Recommended Posts

i am using a form to add data to a mysql database using php. I am using the following code for the query:

mysql_query("INSERT INTO `site_news` (news_name, news_title, news_post) VALUES ('$_SESSION[user]', '$_POST[title]', '$_POST[news]')");

what i want to do is get the form to add the date in (in the form of DD-MM-YYYY ideally). The field is called 'news_testdate' and is set as a date.I am guessing it will be something like this:

mysql_query("INSERT INTO `site_news` (news_name, news_title, news_post, news_testdate) VALUES ('$_SESSION[user]', '$_POST[title]', '$_POST[news]'), 'NOW()'");

or something along them lines.Any ideas?

Link to comment
Share on other sites

i managed to work out a different way, which i think will work excellently in the long run:

$news_date = date("d-m-Y");mysql_query("INSERT INTO `site_news` (news_date, news_name, news_title, news_post) VALUES ('$news_date', '$_SESSION[user]', '$_POST[title]', '$_POST[news]')");

thanks anyway mate :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...