954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Age Verification Script

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:  <a href="http://www.URL.com/Tour/Tour1.html'">http://www.URL.com/Tour/Tour1.html'</a> );
} 
if($month_val >= 0) {
 header('Location:  <a href="http://www.URL.com/Tour/Tour1.html'">http://www.URL.com/Tour/Tour1.html'</a> );
} 
if($day_val >= 0) {
 header('Location:  <a href="http://www.URL.com/Tour/Tour1.html'">http://www.URL.com/Tour/Tour1.html'</a> ); 
 
} else { 
 header('Location:  <a href="http://www.URL.com/notvalidbday.html'">http://www.URL.com/notvalidbday.html'</a> );
}
?>



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

Duke Nukem
Newbie Poster
2 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

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');
}

?>
w_3rabi
Junior Poster
160 posts since Dec 2006
Reputation Points: 18
Solved Threads: 9
 

Nice!!! Thanks for the help!

Duke Nukem
Newbie Poster
2 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

no problem man
take care
;)

w_3rabi
Junior Poster
160 posts since Dec 2006
Reputation Points: 18
Solved Threads: 9
 

This script doesn't work! Calculation is off beat

14music
Newbie Poster
2 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

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;
}
?>
w_3rabi
Junior Poster
160 posts since Dec 2006
Reputation Points: 18
Solved Threads: 9
 

Redirect problem

14music
Newbie Poster
2 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

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!

tkemp
Newbie Poster
2 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

I would do something like this:

<?php

function allowed( $y, $m, $d, $min ) {
	$age = date("Y") - $y - (( date("md") < $m.$d ) ? 1 : 0);
        return ( $age >= $min ) ? true : false;
}

if ( allowed($_REQUEST['year'], $_REQUEST['bmonth'], $_REQUEST['day'], 18) )
{
	header('Location: http://www.URL.com/Tour/Tour1.html');
}
else
{
	header('Location: http://www.URL.com/notvalidbday.html');
}
Ghostt0
Newbie Poster
24 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You