Forum Moderators: coopster
Quick question couldn't find answer searching so I appreicate your time by reading this!
I want to check if user is 13 years old, or greater.
I take in:
<option value="1">January</option> for months
<option value="1">1</option> for days
<option value="2006">2006</option> for years.
How could I use, theses integers to work with the time() to check if they are 13 years or older?
Thank You,
Wesley
$day = 10;
$month = 12;
$year = 1996;
$age_sec = mktime(0,0,0,$month,$day,$year);
$now = [url=http://us2.php.net/manual/en/function.time.php]time[/url](); #current time
$age = (($now-$age_sec)/31556926); #you divide here by the amount of seconds in one year
if(floor($age) < 13) {
echo 'You must be at least 13 to view this content!';
} else {
echo 'Welcome!';
}
Now you just have to use POST variables instead of the ones I have above.
Good luck! :)
Note:
Before PHP 5.1.0, negative timestamps were not supported under any known version of Windows and some other systems as well.
Therefore the above code really won't well with strange birth dates unless they fall within the range based on the system and version of php.
For a better solution, look at the last post [webmasterworld.com]
[edited by: eelixduppy at 5:45 pm (utc) on Mar. 10, 2007]
So why not use a simple button such as "I am.." or "I am not .."
It’ll save coding time!
Or even simpler just state "You ought to be 13+ to access the following.
Now I would be very happy to know if you found any means to online age verification.
Please understand that my object is not to criticize your quest, but simply getting a broad understanding of your quest.
if that is DOB then you could also just straight check the year
hehe...that is true, however, let's say someone was born october of 1988. 2007 - 1988 = 19, however they'd truly be 18. So you kind of have to take into account the month and day, unless you don't want to be that specific. ;)