Forums
This topic is locked
php/mysql redirect after form submit
Posted 07 Jan 2008 02:26:44
1
has voted
07 Jan 2008 02:26:44 Anthony Lamp posted:
I set up a form that send information to mysql, and all that works, but how do i get it so that after you submit the information it redirects you to another page. Replies
Replied 07 Jan 2008 10:50:01
07 Jan 2008 10:50:01 Alan C replied:
Hi,
you can redirect like this . . .
<pre id=code><font face=courier size=2 id=code> # Redirect user to success page
header("Location: reservation_success.htm"
exit;
</font id=code></pre id=code>
care is needed with this because if the current page has started to output anything to the browser you will get the dreaded 'headers already set' error, what that means is that there is something, and it could just be a space character or newline, that the php has started to send to the browser, once that happens the header has been sent and you can't send it again. This can be really difficult to diagnose and sort out. I usually have a form_processor script that does nothing except receive the form input and do the checking, then it redirects to either the success or fail pages that do all the output.
Another way to handle all this is get forms to go, a little application that you drag your form file to, then it generates all the processing for you. it can be tricky to set up, but the code is good and quite easy to edit afterwards.
you can redirect like this . . .
<pre id=code><font face=courier size=2 id=code> # Redirect user to success page
header("Location: reservation_success.htm"
exit;
</font id=code></pre id=code>
care is needed with this because if the current page has started to output anything to the browser you will get the dreaded 'headers already set' error, what that means is that there is something, and it could just be a space character or newline, that the php has started to send to the browser, once that happens the header has been sent and you can't send it again. This can be really difficult to diagnose and sort out. I usually have a form_processor script that does nothing except receive the form input and do the checking, then it redirects to either the success or fail pages that do all the output.
Another way to handle all this is get forms to go, a little application that you drag your form file to, then it generates all the processing for you. it can be tricky to set up, but the code is good and quite easy to edit afterwards.