Page 1 of 1

Two header("Location: ")... in one page...

Posted: Thu Feb 13, 2003 1:41 pm
by Zoram
I've had trouble with having two header("Location: ") 's on the same page... is there some way to make it work?

Posted: Thu Feb 13, 2003 1:45 pm
by daven
you can only have a single header() call function on a page. If you have multiple header() calls, you need to have a conditional (ie..else, switch, etc) statement to choose which one you want to use

Posted: Thu Feb 13, 2003 2:00 pm
by superwormy
Daven is wrong, you can have multiple calls to header() in teh same page.

BUT, if you try and set the same HTTP-HEADER twice, the first just gets overwritten.

Think about it, how are you going to tell a browser that your file is at both http://www.domainname1.com/index.htm AND http://www.domainname2.com/file.htm, or that a file the browser is downloading is BOTH a JPEG AND A GIF file? It's impossible.

What are you trying to accomplish? Why do you want to send them to two different locations?

Posted: Thu Feb 13, 2003 2:27 pm
by Zoram
It was setup as an if then statement... different form submissions sent the user to a different page when they are done... only it blitz when it gets to the redirects.

Posted: Thu Feb 13, 2003 2:51 pm
by daven
*grumble* note to self: make sure that meaning is more clear in future (and/or do not post when also doing IT work). Thanks wormy, I meant what you said, I just obfuscated it a bit.

Zoram: post some of your code so we can take a look at it

Posted: Fri Feb 14, 2003 6:57 am
by martincrumlish
put obstart() at the top of your code before the header calls. This will eliminate any "headers already sent errors" (if thats what the error is, dont know as you didnt post the code or error :) )