Re: weird header() (bug may be)

From: Date: Thu, 12 Feb 2004 13:06:16 +0000
Subject: Re: weird header() (bug may be)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-177510@lists.php.net to get a copy of this message
On 12 Feb 2004 at 17:20, adwinwijaya wrote: > Hello php-generaler's , > > I have a script like this : > > if($foo == 'something'){ > header('Location:to_another_page.php') ; > }else > { > do another thing in here > } > > header('Location:to_previous_page.php'); > > > I got a problem ... when $foo == 'something' .. it wont redirect me to > to_another_page.php .... but if I put die(); after calling header(); .. > it will work ... > > is this the bug ? You're joking, right? Your second "header" statement is outside the if/else loop, so it's executed every time, obviously. This in turn means that your script will always redirect to "previous_page.php", unless, of course, you kill it before it gets to the second "header" statement. Suggestion: read up on control structures (chapter 11 in the PHP manual).

« previous php.general (#177510) next »