Page 1 of 1
registration date added to registering
Posted: Fri Jan 09, 2009 8:51 am
by chris_s_22
what i want to achieve is that when people sign up i want to have the date entered into my database
so far all i done is create a regdate feild to the database the "type" i used is "date"
not sure what the code would be, please help or direct me to a tutorial that explains how and what to do
pinkangel_@hotmail.co.uk
Re: registration date added to registering
Posted: Fri Jan 09, 2009 9:02 am
by mattpointblank
You need to add some code to your registration process so that when the user's info is stored in the database, it also includes the current date, which you can get using php's date() function. You'd just need to add this into the SQL query that's adding the data.
On the other hand, if you add a field with the type 'timestamp' on your database (assuming you're using MySQL), it will automatically set itself to the date the row was updated, without any input from you.
Re: registration date added to registering
Posted: Fri Jan 09, 2009 10:18 am
by watson516
mattpointblank wrote:You need to add some code to your registration process so that when the user's info is stored in the database, it also includes the current date, which you can get using php's date() function. You'd just need to add this into the SQL query that's adding the data.
On the other hand, if you add a field with the type 'timestamp' on your database (assuming you're using MySQL), it will automatically set itself to the date the row was updated, without any input from you.
Can't you just put NOW() into the mysql statement for the current date?
Re: registration date added to registering
Posted: Fri Jan 09, 2009 10:36 am
by mattpointblank
Oops, yeah, that too.
Re: registration date added to registering
Posted: Fri Jan 09, 2009 3:48 pm
by chris_s_22
thx for your replys guys i ended up using this
Code: Select all
// Get the current date
$regdate=date("Y-m-d");
// And then this to store the information in the database
$query = "insert into user (regdate) values (''$regdate')";
this works, just wanted to check with you guys if there was a reason why this was incorect or any reason why i shouldnt do it this way