PDA

View Full Version : How do i Link to a page after posting a form in PHP



cglaister
March 8th, 2005, 08:44 AM
Hi, i have got a form working on my site www.hooopla.co.uk (http://www.hooopla.co.uk), using the example code from this site. However i can't figure out how to make it take you to the next page once you hit submit.

I want it to automatically go to a new html page after you hit the submit button. At the moment it echos a short piece of text informing you it has been sent then leaves you there.

Thanks,

Chris.

SlowRoasted
March 8th, 2005, 10:23 AM
well you can set the action of your form to the page you want and then have the script to send the infomation on that page.

cglaister
March 8th, 2005, 10:54 AM
Thanks for the advice, but i don't really understand!

Could you be more specific? I'm completely new to PHP and HTML,

Chris.

lucidsurf
March 8th, 2005, 11:34 AM
So, basically you want to redirect the user to another page after the form has been processed?

If so, add the following line of code to the end of your PHP file:

Header("Location: mypage.html");

This line should go before the last ?> tag and simply change the name 'mypage.html' to whichever page you actually want to redirect the viewer to.

Also, you may want to remove sections of the script that say "Echo" or "Print", as these output that message text to the viewer's screen.

Good luck!

cglaister
March 9th, 2005, 06:39 AM
Great, thanks very much, that worked perfectly!