Jump to content

Sign Up Page - Birth Date???


evil_stevo

Recommended Posts

$username = $_POST['username'];
$password = $_POST['password'];
$month = $_POST['month'];
$day = $_POST['day'];
$year = $_POST['year'];

$query = mysql_query("INSERT INTO users VALUES ('','$username','$password','$month','$day','$year')
mysql_query($query);

 

The code above is a sample of what I have but what I want is to store an entire birthdate in ONE SQL cell. More like this...

 

$username = $_POST['username'];
$password = $_POST['password'];
$month = $_POST['month'];
$day = $_POST['day'];
$year = $_POST['year'];

$query = mysql_query("INSERT INTO users VALUES ('','$username','$password','$birthdate')
mysql_query($query);

 

How is this possible? Can I do this and actually use it efficiently in the future?

Link to comment
Share on other sites

The short answer :)

$birthday = $month . $day . $year

 

The longer answer...

Some may disagree, but storing a date as a unix timestamp is almost always more efficient (in both storage, query speed, and ease of manipulation).

 

You can use php's strtotime function to get a unix timestamp from date formats.  Hopefully this helps!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.