Page 1 of 1

Difficulty redirecting users after form submission

Posted: Fri Feb 20, 2009 10:59 am
by WillUK
Hiya,

I am building a script that checks to see whether the user accepts the site Terms & Conditions.
If the user checks "accept", the script should redirect to 'client_profile.php'.
If the user checks "decline", it should print an error message....

For some reason, the script runs, but it will not process any output to screen...

Whether I check "accept" or "decline" makes no difference....A blank white screen appears - except for the inclusion of the site's header and footer...

Here's my scripts:

Title: legalcheck.php

Code: Select all

 
 
include ("inc/header.php");
$SiteFunctions->PrintNav("left");
 
 

Code: Select all

  <div class="column_main"><br /><p> Please click on the link to view the site <a href="terms.php" id="terms">  Terms & Conditions </a></p><br /><p> You must accept the Terms before continuing into the website. </p><br /><form method="post" action="check_legal_check.php"/"><input type="radio" value="decline" name ="legals" id="decline" checked="checked" />I do not accept the terms<br /><input type="radio" value="accept" name ="legals" id="accept" />I understand and accept the Terms, and wish to proceed into the site<br /><p><input type="submit" value="submit" /></p></form><h2> Please note: you cannot proceed into the website unless you agree to these Terms. </h2><h2> If you do not agree, please log out of the system, as you cannot proceed any further. </h2></div>    

Code: Select all

 
include ("inc/footer.php");
 

Title: check_legal_check.php

Code: Select all

 
include ("inc/header.php");
$SiteFunctions->PrintNav("left");
 
if (isset($_POST['submit']))
{
//$message = NULL; //clear the variable.
if(isset($_POST["accept"])){
session_start();
header ("location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) ."./client_profile.php");
} else {
if (isset($_POST["decline"])){
$message .= "<p>You must accept the Terms to continue to the website</p>";
        }
    }
}
 
include ("inc/footer.php");
 
Any help would be apprecitated :)

Re: Difficulty redirecting users after form submission

Posted: Fri Feb 20, 2009 11:46 am
by p3rk5
session_start(); must go before any output on the page, including <html> tags.

Re: Difficulty redirecting users after form submission

Posted: Fri Feb 20, 2009 12:42 pm
by WillUK
thanks P3rk5

But the session_start() doesn't come after any HTML....
Unless the included files (header.php etc), class as HTML??? In which case the session_start() function does begin after....
But I don't think included files count....or do they???

Re: Difficulty redirecting users after form submission

Posted: Fri Feb 20, 2009 12:47 pm
by WillUK
I've tried moving the session_start(); to the beginning of the scripts, but the output is still 'blank'...am tempted to say the output is null, but that not be correct :evil:

Re: Difficulty redirecting users after form submission

Posted: Fri Feb 20, 2009 4:02 pm
by WillUK
I've sorted the problem out...I was testing the 'value' rather than the 'name' of the form....I also didn't apply all of the necessary attributes to the 'submit' button within the form...

Thanks anyway.