Re: header("Location:...") fails

From: Date: Wed, 13 Jan 2010 19:51:04 +0000
Subject: Re: header("Location:...") fails
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-301076@lists.php.net to get a copy of this message
On Wed, Jan 13, 2010 at 2:39 PM, Richard S. Crawford <rscrawford@mossroot.com> wrote: > Now, even if $numprojects is 1, 2, 3, etc., the header() command is not > executed. Strangely, a header("Location") command later on in the script > *is* executed. I've output the value of $numprojects, so I know that it's > greater than 0, so the command > header("Location:managebudget.php?e=1&pid=$pid"); *should* be executed... > but it isn't. (Weirdly, if I put a die() command *after* this header() > command, it works... but it seems pathologically inelegant to do so.) > > Obviously, I'm missing something incredibly basic. Can anyone help me figure > this out? It isn't "pathologically inelegant" at all. All the header function does is output the header; it does not stop script execution. If you don't stop the script yourself, it will continue to execute. You probably want to send a message right after the header call anyway, just in case someone is using a browser that does not handle redirection. Andrew

« previous php.general (#301076) next »