10-29-2016, 11:58 AM
You would basically have to do your own validation... If this isn't exact, it's close. Notice you can test the logic by using the birthday I commented out instead of the form input....
//date in mm/dd/yyyy format; or it can be in other formats as well
//to test it use this line instead of the Input::get line
// $birthDate = "12/17/1983";
$birthDate = Input::get('birthDate'); //give your form input a name of birthDate in mm/dd/Y format.
//explode the date to get month, day and year
$birthDate = explode("/", $birthDate);
//get age from date or birthdate
$age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2]))) > date("md")
? ((date("Y") - $birthDate[2]) - 1)
: (date("Y") - $birthDate[2]));
if($age > 17){
//continue your form processing
} else {
Redirect::to('join.php?err=Sorry+you+must+be+18+to+join');
};
//date in mm/dd/yyyy format; or it can be in other formats as well
//to test it use this line instead of the Input::get line
// $birthDate = "12/17/1983";
$birthDate = Input::get('birthDate'); //give your form input a name of birthDate in mm/dd/Y format.
//explode the date to get month, day and year
$birthDate = explode("/", $birthDate);
//get age from date or birthdate
$age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2]))) > date("md")
? ((date("Y") - $birthDate[2]) - 1)
: (date("Y") - $birthDate[2]));
if($age > 17){
//continue your form processing
} else {
Redirect::to('join.php?err=Sorry+you+must+be+18+to+join');
};