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
https://forums.phpfreaks.com/topic/221565-sign-up-page-birth-date/
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!

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.