Redirect Problem/Keeps 404'ing

I need to do an age verification for 18 and older and for the life of me can’t get it to work. I don’t know if I’m having a blonde moment, or if anyone has a better code to use out there I am open for suggestions. My blonde head is going bald!!!

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

Smoke Free System Please Verify Your Age, you must be 18 to enter I verify I am over 18 | I'm not 18 yet [/php]

I think you need to change…

[php]session_start(");[/php]

To

[php]session_start();[/php]

Also what value are you passing in for $redirect, I don’t see where you are assigning it.

What Topcoder said and also do not use $_REQUEST[‘over18’]. You should be well aware of how you are going to retrieve that value ($_GET[‘over18’]) and if you’re not then you shouldn’t be passing values.

Maybe what I would do is have them as two seperate pages

(verify.php) …
[php]

<?php session_start(); // check if they have already been verified if($_SESSION['over18']){ header('location: pageForVerifiedPeople.php'); exit(); ?> Smoke Free System Please Verify Your Age, you must be 18 to enter I verify I am over 18 | I'm not 18 yet [/php]

(verifyCheck.php)…
[php]

<?php session_start(); if ($_GET['over18'] == 1) { $_SESSION['over18'] = 1; header('Location: pageForVerifiedPeople.php'); exit() } else { header('location: http://www.google.com'); exit(); } ?>

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service