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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Zoram
Forum Contributor
Posts: 166
Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:

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

Post by Zoram »

I've had trouble with having two header("Location: ") 's on the same page... is there some way to make it work?
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post 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
superwormy
Forum Commoner
Posts: 67
Joined: Fri Oct 04, 2002 9:25 am
Location: CT

Post 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?
User avatar
Zoram
Forum Contributor
Posts: 166
Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:

Post 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.
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post 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
martincrumlish
Forum Newbie
Posts: 13
Joined: Mon Oct 14, 2002 10:46 am

Post 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 :) )
Post Reply