I need to develop a script that will direct users to one area if they are under 13 and to another if they are 13 or older.
I am barely a beginner when it comes to PHP, I found the following script online, can anyone provide some direction on how to modify and implement it? Thanks!
*********
function coppa_check($day, $month, $year){
//check to see if we have a 2 digit year. If so convert it to standard 4 char format
if (strlen($year) == 2){$year = "19" . $year;}
//First do a check to see if we have a good date
$isgood = checkdate($month, $day, $year);
//dump it if the date is bad...
if ($isgood != 1){
return FALSE;
}
//do some date to timestamp conversions
$birthdate = mktime(0,0,0,$month,$day,$year);
$today = time();
//now do them back so we can get some different info.
$old_date = getdate($birthdate);
$current_date = getdate($today);
//error check to make sure the date's not in the future
if ($current_date[year] < $year){return FALSE;}
//adjust for day of the month and get final age.
if ($current_date[yday] >= $old_date[yday]){
$age = $current_date[year] - $year;
}else{
$age = ($current_date[year] - $year) -1;
}
//age range check
if ($age < 13 || $age > 120){
return FALSE;
}
//fallthru and spit back the actual age just for fun.
return $age;
}//end coppa_check
?>
Example
if ($age = coppa_check(8, 5, 1971)){
echo "$age years old";
}else{
echo "Non-compliant age";
}
I am barely a beginner when it comes to PHP, I found the following script online, can anyone provide some direction on how to modify and implement it? Thanks!
*********
function coppa_check($day, $month, $year){
//check to see if we have a 2 digit year. If so convert it to standard 4 char format
if (strlen($year) == 2){$year = "19" . $year;}
//First do a check to see if we have a good date
$isgood = checkdate($month, $day, $year);
//dump it if the date is bad...
if ($isgood != 1){
return FALSE;
}
//do some date to timestamp conversions
$birthdate = mktime(0,0,0,$month,$day,$year);
$today = time();
//now do them back so we can get some different info.
$old_date = getdate($birthdate);
$current_date = getdate($today);
//error check to make sure the date's not in the future
if ($current_date[year] < $year){return FALSE;}
//adjust for day of the month and get final age.
if ($current_date[yday] >= $old_date[yday]){
$age = $current_date[year] - $year;
}else{
$age = ($current_date[year] - $year) -1;
}
//age range check
if ($age < 13 || $age > 120){
return FALSE;
}
//fallthru and spit back the actual age just for fun.
return $age;
}//end coppa_check
?>
Example
if ($age = coppa_check(8, 5, 1971)){
echo "$age years old";
}else{
echo "Non-compliant age";
}