I am trying to create a script for a website that will ask the user to agree to a disclaimer before entering the site. I was attempting to use sessions to store whether the disclaimer has been to agreed to already so that it will only ask once and I can reference that session data across multiple pages on the site.
I have it working but there’s a logical error I can’t seem to figure out with the redirecting. I have three main files
- disclaimer_form.php --which is the form for the user to agree to the terms.
[code]<?php
#start the session before any output
session_start();
if($_GET[‘error’] == “1”){ $error_code = 1;
//this means that there’s been an error and we need to notify the customer
}?>
Please read and agree to our Disclaimer in order to gain access
<?php if ($error_code){ echo "By entering this web site you agree to the following: |
|
I agree to the terms of use
<?php
if ($error_code && !($_GET['agree'])){
echo " Please check the box above to agree to our disclaimer. ";
}
?>
|
-
demo.php --my test page to see if it works
in the html header before any output I placed the php script:
[php]<?php
require($_SERVER[‘DOCUMENT_ROOT’]."/disclaimer.php");
?>[/php] -
disclaimer.php – which determines using sessions whether a user has already agreed to the terms. If not, it will redirect to the disclaimer form. If a session already exists, it is supposed to let the user into the proper page. Unfortunately it is grabbing a random index page on my server even after I moved the index file to a different location.
[php]