Hello,
I have been banging my head against a brick wall trying to see what I’m doing wrong.
In the following code (test if person submitting form is aged over 18 based on birthdate) “1” is correctly returned if the year of birth is 1988 or before.
However both subsequent tests return “0” even when the input should evaluate to being over 18. (The input variable names from the form are correct.)
I’m truly stuck!
$birthyear = $_REQUEST['birthyear'];
$birthmonth = $_REQUEST['birthmonth'];
$birthday = $_REQUEST['birthday'];
$today = date("d");
$thismonth = date("M");
$thisyear = date("Y");
if($thisyear - $birthyear > 18){
$ageflag = "1";
}
elseif (($thisyear - $birthyear = 18) && ($thismonth - $birthmonth > 0)){
$ageflag = "2";
}
elseif (($thisyear - $birthyear = 18) && ($thismonth - $birthmonth = 0) && ($today - $birthday >= 0)){
$ageflag = "3";
}
else {
$ageflag = "0";
}
ADMIN EDIT: Changed COLOR tag to CODE for easier distinction of code from other text