help with linking to a success page after form is submitted

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
malloy
Forum Newbie
Posts: 15
Joined: Fri Jun 01, 2007 2:02 am
Location: Melbourne, Australia

help with linking to a success page after form is submitted

Post 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
bdlang
Forum Contributor
Posts: 395
Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US

Post 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.
malloy
Forum Newbie
Posts: 15
Joined: Fri Jun 01, 2007 2:02 am
Location: Melbourne, Australia

Post by malloy »

Thanks for that bdlang,

It worked a treat.

Have a great day!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply