Click to See Complete Forum and Search --> : PHP Redirect Question
shaggy112
07-28-2001, 01:48 PM
Hey,
I have a site going with PHP and MySQL. Whenever I submit a form into the db, the I am left with the same page that I started with.
In other words, I want to be able to redirect to another page after a form submission.
I know this is simple, but I can't remember how it was done.
thx
bdg1983
07-28-2001, 02:09 PM
header("Location:index.php");
shaggy112
07-28-2001, 04:27 PM
thanks.
i am unfamiliar with http headers. where do i need to put this in my script so that the form will redirect after submission. Here is the error that I get now.
Warning: Cannot add header information - headers already sent by (output started at /var/www/docs/vendingdevel/header.inc:14) in /var/www/docs/vendingdevel/cont_update.inc on line 9
i am also using php include files, so header.inc is included into the php file.
DaMasta
07-28-2001, 05:06 PM
You have to use the redirect before any html is sent to the browser.
shaggy112
07-28-2001, 05:08 PM
ok.
that is kinda what i was thinking. how then would i have a form that would take you to another site, after the form was processed?
thx
DaMasta
07-28-2001, 05:28 PM
For example:
<form action=anotherphpfile.php method=post>
< all your html code here>
</form>
In "anotherphpfile.php", you'll have the redirect first. You may not even see any html on anotherphpfile.php depending on the line speed.