0

Hi there, I have a question related to this topic, i dont know if I should make a new thread or how to make a new thread.

I am making an adult website and I just need a disclaimer and 2 buttons one that verifies age or one that redirects them out of the site.

Here is the code someone told me I would have to use

if (cookie doesn't exist) {
  print agreement
  if (agreed) {
    make cookie
    redirect
  }
} else {
  print real page
}

I was hoping someone could make this in php for me, cause idk what I am doing.

for now agreement will be "You must be at least 18 years of age to enter this website (21 years of age in the USA)"

if they confirm their age to be of majority I want to direct them to verified.php

If they confirm they aren't of majority to go to exit.php

3
Contributors
5
Replies
9
Views
6 Years
Discussion Span
Last Post by smackthat9876
0

PHP is a very poor language choice for this, if i were you i'd read up on libcgi and just do the whole thing in Haskell.

0

My entire site is already in php

this is what i found so far:

verify.php

<?php
session_start();
if ($_REQUEST["over18"] == 1) {
    $_SESSION["over18"] = 1;
    header("Location: " . $_REQUEST["redirect"]);
}
?>
<html>
    <head>
        <title>Verify Your Age</title>
    </head>
    <body>
        <a href="verify.php?over18=1&redirect=<?=$redirect?>">I am over 18</a> | 
        <a href="http://www.google.com/">Get me out of here!</a>
    </body>
</html>

require_verification.php

<?php
session_start();
if ($_SESSION["over18"] != 1) {
    header("Location: verify.php?redirect=" . $PHP_SELF);
}
?>

content_page.php

<?php include("require_verification.php");  ?>
<html>
    <head>
        <title>Sensitive Content</title>
    </head>
    <body>
        <img src="something_sensitive.jpg" alt="EEK!!!" />
    </body>
</html>
</html>

Now will I need

<?php include("require_verification.php");  ?>

On every page that my website has or is it ok only for the front page and/or where /nsfw/ start (the front page of my site will be sfw while everything in /nsfw/ will be adult content)

0

My 2p:

It's difficult to stop under 18s from entering a site. You probably need to include a disclaimer and link, on a splash page/landing page. Once link is pressed, set a session variable to allow pages to be seen. On logout, session is destroyed. [You could also destroy an existing session if the referring page is outside the domain or does not exist - but this breaks if you manually enter an url or possibly use a bookmark]. If session is not present on any page, header redirect to the splash page.

I was playing with something similar here (I have a session implementation on http://diafol.org/blacknun/blacknun/index.php ) It's just something I was playing with. It doesn't have the referer implementation, but as I say, it's not foolproof.

4 pages:

top of splash screen:
redirect to main page if a session is set
the page has link to accept_page

session_start();
if(isset($_SESSION['adult'])){
	header("Location: index.php");
}

top of site pages:
redirect to splash screen if no session set

session_start();
if(!isset($_SESSION['adult'])){
	header("Location: splash.php");
}

top of accept_page:
set session var and redirect to main page

session_start();
$_SESSION['adult'] = 1;
header("Location: index.php");

logout page
kills session and redirects to main page - which should redirect to splash page (you could set redirect to splash page)

session_start();
session_destroy();
header("Location: index.php");

BTW, each header() should be succeeded by an exit();

Edited by diafol: n/a

0

@thetooth I read somewhere the session method is the correct way to do it, because you have to verify you are 18 after every browser close, this is a more sure means of proving they are 18 because more than one persons who are / are not 18 could use the same computer and visit my site. Whereas with setting a cookie that computer is always logged in as 18 regardless which family member uses the computer and or 18+ or not.

@arday, your help is appreciated yet is still over my head as I am new to PHP.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.