Page 1 of 1

form question... please help

Posted: Wed Oct 04, 2006 2:19 pm
by bubs
I have a form that works but everything is in one file. I want to separate the thank you page from the rest of the stuff. How would I go about doing that?

is there a redirect snippet or something I can put in there so that when it tries to display the thanks you it would redirect you to the html page i have instead?

Posted: Wed Oct 04, 2006 2:40 pm
by SpecialK
This was recently answered

viewtopic.php?t=56415

Your modification to it would be something along these lines

Code: Select all

if($validated){

   header("location: http://www.yoursite.com/thank_you.html");
}else{
  //the code to display to the user because it is not validated
}

Posted: Wed Oct 04, 2006 2:52 pm
by Luke
Let's promote good practice here... make sure no headers have been sent first.

Code: Select all

function redirect($location){
    if(!headers_sent()){
        header('Location: ' . $location);
    }
    else{
        echo "<a href='" . $location . "'>Continue</a>";
    }
    exit;
}
if($validated){
   redirect("http://www.yoursite.com/thank_you.html");
}else{
  //the code to display to the user because it is not validated
}

fantastic

Posted: Wed Oct 04, 2006 6:57 pm
by bubs
Very cool! Thanks guys

Posted: Wed Oct 04, 2006 9:14 pm
by Dave2000
Just a quick question. I often see people checking if a header has been sent before redirecting. However, what is the point in this? Surely if a header has been sent, you will see it has when you test the script...

Shears :)

Posted: Thu Oct 05, 2006 9:52 am
by Luke
umm... I generally don't like PHP Errors to show up on my web sites... for some strange reason I just feel that it's unprofessional. :roll:

That's kind of a strange question... that's like asking... "Why would you check that there is a database connection before attempting to use one... when PHP would report this via an Error?"

As a programmer, it's your responsibility to be paranoid and trust nothing.