Duke SNIPPED Nukem will only allow 18 and above on his site. It seems like my html page is correct and my php is the problem. Anyone have any answers they would like to share with me? MAY JUSTICE REIGN SUPREME!!!!!

<?php
$month = $_REQUEST['bmonth'];
$day = $_REQUEST['day'];
$year = $_REQUEST['year'];
$this_day = date(d);
$this_month = date(m);
$this_year = date(Y);
$day_val = $this_day - $day;
$month_val = $this_month - $month;
$year_val = $this_year - $year;
if($year_val >= 19) {
 header('Location: [URL]http://www.URL.com/Tour/Tour1.html'[/URL]);
} 
if($month_val >= 0) {
 header('Location: [URL]http://www.URL.com/Tour/Tour1.html'[/URL]);
} 
if($day_val >= 0) {
 header('Location: [URL]http://www.URL.com/Tour/Tour1.html'[/URL]); 
 
} else { 
 header('Location: [URL]http://www.URL.com/notvalidbday.html'[/URL]);
}
?>

:twisted: :twisted: :twisted: :twisted: :twisted: :twisted: :twisted: :twisted: :twisted: :twisted: :twisted: :twisted: :twisted: :twisted: :twisted: :twisted: :twisted:

dude you should remove the three conditions and put em in one condition so the code should look something like this

<?php
$month = $_REQUEST['bmonth'];
$day = $_REQUEST['day'];
$year = $_REQUEST['year'];
$this_day = date(d);
$this_month = date(m);
$this_year = date(Y);
$day_val = $this_day - $day;
$month_val = $this_month - $month;
$year_val = $this_year - $year;
if($year_val >= 19&&$month_val >= 0&&$day_val >= 0) {
 header('Location: http://www.URL.com/Tour/Tour1.html');
} 
else {     
 header('Location: http://www.URL.com/notvalidbday.html');
}

?>

try this one

<?php
$allowed_age = 19;
$bdate = strtotime($_REQUEST['y'].'-'.$_REQUEST['m']."-".$_REQUEST['d']);
$age = (time()-$bdate)/31536000;
if($age >= $allowed_age) {
	header('Location: http://www.URL.com/Tour/Tour1.html');
	exit;
} 
else {     
	header('Location: http://www.URL.com/notvalidbday.html');
	exit;
}
?>

This works fine. Thanks. I was trying to add set cookie to expand on this, which works, but resets the cookie value each time. I want to check if someone has already entered their age and if so, direct them to the appropriate response page. i.e. - don't want a youth hitting back button and enter different age. I know this is easily circumvented anyways, but ESRB requires it for adult game trailers, etc. Here is what I have so far -

<?php
$allowed_age = 18;
$bdate = strtotime($_REQUEST['year'].'-'.$_REQUEST['month']."-".$_REQUEST['day']);
$age = (time()-$bdate)/31536000;
if($age >= $allowed_age) {
        setcookie('legal', 'yes', time() + 31556926, '/', '.'.$_SERVER['SERVER_NAME']);
        header('Location: http://www.myserver.com/adult.html');
        exit;
}
else {
        setcookie('legal', 'no', time() + 31556926, '/', '.'.$_SERVER['SERVER_NAME']);
        header('Location: http://www.myserver.com/minor.html');
        exit;
}
?>

Here is what the cookie looks like if I retrieve it -
for minor:
noArray ( [0379923826258bc7cbcfa89cd386917d] => e33f27206e07981d495d11f70581e790 [29e6895b11c34b79d161fe2a6f1702f0] => b7b4ff91eb8090ad2f85d6a2100d3c4e [legal] => no )

for adult:
yesArray ( [0379923826258bc7cbcfa89cd386917d] => e33f27206e07981d495d11f70581e790 [29e6895b11c34b79d161fe2a6f1702f0] => b7b4ff91eb8090ad2f85d6a2100d3c4e [legal] => yes )

Thanks for any help in advance!

This article has been dead for over six months. Start a new discussion instead.