Page 1 of 1

help with linking to a success page after form is submitted

Posted: Sun Jun 10, 2007 11:54 pm
by malloy
Hi everyone,

I have a simple query for you all.

I have made a form which uses php to email the information to a user. I was just wondering how i would go about linking to a success page after the form has been submitted.

My email.php code ends like this below. I am currently using an echo command in the mean time.
I'm not sure where the command would go to call the success.html or php page either. In my form.php or the email.php?


mail($sendTo, $subject, $headers);


echo "Thankyou"

?>


Any assistance would be greatly appreciated.

Thanks,

David

Posted: Mon Jun 11, 2007 12:43 am
by bdlang
Look at using header() to redirect the user to the page you want, e.g.

Code: Select all

if ( mail($sendTo, $subject, $headers) != FALSE ) {
    header("Location: success.php");
}
Please keep in mind that when using header(), you can't display any output to the user in that script unless you want to use output buffering.

Posted: Mon Jun 11, 2007 2:11 am
by malloy
Thanks for that bdlang,

It worked a treat.

Have a great day!

Posted: Mon Jun 11, 2007 2:39 pm
by feyd
Make sure that a full URL (http:// et al) is included in the header() redirection. Standards compliance requires it and any browser that is standards strict will not redirect.