registration date added to registering

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
chris_s_22
Forum Commoner
Posts: 76
Joined: Wed Dec 31, 2008 2:05 pm

registration date added to registering

Post 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
mattpointblank
Forum Contributor
Posts: 304
Joined: Tue Dec 23, 2008 6:29 am

Re: registration date added to registering

Post 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.
watson516
Forum Contributor
Posts: 198
Joined: Mon Mar 20, 2006 9:19 pm
Location: Hamilton, Ontario

Re: registration date added to registering

Post 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?
mattpointblank
Forum Contributor
Posts: 304
Joined: Tue Dec 23, 2008 6:29 am

Re: registration date added to registering

Post by mattpointblank »

Oops, yeah, that too.
chris_s_22
Forum Commoner
Posts: 76
Joined: Wed Dec 31, 2008 2:05 pm

Re: registration date added to registering

Post 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
Post Reply