Page 1 of 1

Newbie-after form submission return to home page?

Posted: Sun Sep 13, 2009 6:45 pm
by ducatigirl67
Hi,
php is a foreign language to me, dont know how to do 2 things.
When the form is filled out and submitted, then the "thank you" message is displayed on a blank white page.
I want the "thank you" to be displayed on a webpage with the navigation etc.
Or when the message comes up for it to be in a new window, so user can just go to website, currently, the fill form out, submit, message appears and website is gone.
I tried to add a url with target blank inside the code but it did not work.
I would really appreciate your help.

Heres the bit of code I think is needing variables.

// if the redirect option is set: redirect them
if ($redirect) {
header("Location: $redirect");
exit;
} else {
echo "Thank you for your submission, someone will be in contact with you soon.\n";
echo "<br><br>\n";

exit;
}

// <---------- THE END ----------> //

Re: Newbie-after form submission return to home page?

Posted: Sun Sep 13, 2009 6:51 pm
by Eric!
Here's an example. $redirect needs to be the url, if it is undefined then you'll get the simple thank you text, if $redirect is defined it will go to the redirected link. You should not echo anything to the browser (no HTML code) before calling the header() function.

Code: Select all

// if the redirect URL is set: redirect them
$redirect="http://yourdomain.com/thank you sucker.html";
if (isset($redirect)) {
header("Location: $redirect");
} else {
echo "Thank you for your submission, someone will be in contact with you soon.";
echo "<br /><br />";
exit;
}
edit: removed urlencode, because of stupid %2F

Re: Newbie-after form submission return to home page?

Posted: Sun Sep 13, 2009 6:58 pm
by Eran
Don't use urlencode on any part of the URL containing functional slashes if you want them to work.

Re: Newbie-after form submission return to home page?

Posted: Sun Sep 13, 2009 7:13 pm
by ducatigirl67
I pasted that snippet given to me, and it does not work. Says thankyou.htm not found.
I am VERY VERY new to php.
Can you write it out for me how it will work? Please.

Re: Newbie-after form submission return to home page?

Posted: Sun Sep 13, 2009 7:16 pm
by ducatigirl67
ahhh I got it, thank you to the last person who posted, I removed the urlencode bit.
I'm rapt!
Thanks