Jump to content

[SOLVED] Age Validation Issue


wwfc_barmy_army

Recommended Posts

Hello.

 

I have this code to check the age of people signing up:

 

<?php
$month = $_POST['birthmonth'];
$day = $_POST['birthdate'];
$year = $_POST['birthyear'];
// create timestamp for user's age
$user_timestamp = mktime(12,0,0,$month,$day,$year);
// work out difference between now and the user's timestamp
$age = $time() - $user_timestamp;
// convert $age timestamp to years (1yr = 31556926secs)
$age = $age / 31556926;
if($age < 18) {
echo "18-";
} else {
echo "18+";
}
?>

 

Although i'm getting the following error:

 

Fatal error: Function name must be a string in myfilename on line 68

 

Line 68 being:

$age = $time() - $user_timestamp;

 

Any ideas?

 

Thanks.

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/75548-solved-age-validation-issue/
Share on other sites

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.