Forum Moderators: coopster

Message Too Old, No Replies

php age verification script

         

vatel

10:55 pm on Jan 29, 2009 (gmt 0)

10+ Year Member



Hello,
I am going to build a website for alcoholic beverages. We are required to verify the age of visitors accessing the website. That could easily be solved with JavaScript, but unfortunately the age must be verified on each page the visitor access (not just the gateway page).
So basically I am looking for a php script that checks the age on an initial page AND on every other page of the site. Of course if you verified your age at the entrance you should not be asked to re-verify on any other page, but if you are accessing the site from some pages other than the initial page you should be redirected to the initial verification page.
I hope I explained that clearly enough.
Do you have any suggestion?
Thanks
Vatel

Little_G

11:07 pm on Jan 29, 2009 (gmt 0)

10+ Year Member



Hi,

This is similar to logging into a member only area I suppose. The common way is to use cookies.
The basic logic would be: On ever page, check for cookie if it's there continue, if not redirect to verification page which sets cookie if correct age is given.

Andrew

rob7591

11:08 pm on Jan 29, 2009 (gmt 0)

10+ Year Member



on your entrance page, have a form like this:

<form method="get" action="main.php">
<input type="hidden" name="verified" value="y" />
<input type="submit" value="I am Over 21" />
</form>

Then on top of your main.php (this should be your main page obviously):

<? $_SESSION['v'] == $_GET['v']; ?>

Then on the rest of your pages (including main.php underneath the code above).

<?
if ($_SESSION['v'] != 'y') {
header('Location: denypage.php');
}
?>

denypage.php is the page you want them to see if they are denied. You should be able to make somethin out of those snippets.

penders

12:01 am on Jan 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



We are required to verify the age of visitors accessing the website.

Just curious, how are you verifying their age? Or are you just asking the question, "Are you over 21?" (Y/N) ?

vatel

4:51 pm on Jan 30, 2009 (gmt 0)

10+ Year Member



Penders, I agree that the procedure is not very rigorous, but law requires to take measures to prevent minors from accessing alcoholic beverages related websites. Since it would be rather impractical to actually verify the age of each visitor, what's happening is that websites basically ask if the visitors are of legal age. This is done either with a calculation from their birth date or simply asking if they are over 21 (or watever age is required in a given country). Of course this procedure is not very effective, but it shows that at least some measures have been taken to prevent access to the site. The idea, though is to prevent at least who stated to be underage, if any does state that, or who did not declare their age to view the site.