lienny
asked on
redirect after form submission
Hi,
I'm having a problem using the header function...it gives me an error saying headers already sent. The issue I think lies in the fact that I have a page that displays a query from a previous form and then another form that lets the user addes infinite numbers of records. After submit I'd like to take the user to a new page that list what was just inserted.
I'm having a problem using the header function...it gives me an error saying headers already sent. The issue I think lies in the fact that I have a page that displays a query from a previous form and then another form that lets the user addes infinite numbers of records. After submit I'd like to take the user to a new page that list what was just inserted.
You can run database queries before redirecting as long as you don't output any results, any such output (as listed above) will result in the header already sent error because the header must be sent before the output content is generated.
you can use output buffering to work around it but its really better to just fix the script, example:
ob_start(); //top of page
//various code and header redirect
ob_end_flush();
ob_start(); //top of page
//various code and header redirect
ob_end_flush();
ASKER
been doing some research...it won't work if I call includes before that.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If its going to cause a problem modifying your script to work because of the way it is set up you might wish to consider an alternative redirect method:
javascript:
<script language="JavaScript">
window.location="http://www.site.com/page.html";
</script>
or Meta Refresh (between the head tags)
<meta http-equiv="refresh" content="0;URL=http://www.site.com/page.html">
javascript:
<script language="JavaScript">
window.location="http://www.site.com/page.html";
</script>
or Meta Refresh (between the head tags)
<meta http-equiv="refresh" content="0;URL=http://www.site.com/page.html">
ASKER
thanks for coming to my rescue again!...but i got it to work...just need to take a break from looking at the code before I knew what I was doing wrong. =D
:)
In my book coffee is the short term solution but a good nights sleep and fresh eyes renders the best results.... if only there was more time in the day.
In my book coffee is the short term solution but a good nights sleep and fresh eyes renders the best results.... if only there was more time in the day.
php echo/print
new lines
html tags
Ideally it should go right at the top of the page (just after the form processing if applicable)