I’m trying to check if the birthday the user inputs in my html form is over 18 years.
function validate_form() {
$errors = array();
$insert = array();
# stores date of birth.
$insert['bday'] = array_key_exists('bday', $_REQUEST) ? $_REQUEST['bday'] : null;
# this is line 66
if (date('Y') - $insert['bday'] <= 18) {
$errors[] = "<p> You need to be 18 years or older to create an account.</p>n";
}
If for example the user chooses 2003 and below, the form submits successfully. if the user selects 2005 and above the error message displays as it should. However if i select 09/01/2004 (which was more than 18 years ago now) i still get the error message.
I also get this warning when the error page displays:
Warning: A non-numeric value encountered in C:xampphtdocsfilnamefilenamepagename.php on line 66