This is not a bug. Here you expect that the script should end executing after the statement:header('Location:to_another_page.php') if the "if" statement is true. But it won't and it proceeds to the next statement; the next header statement:header('Location:to_previous_page.php');
An "exit" statement after the first header will solve the problem. With most browsers, if multiple redirect headers are received, the last instruction is followed. I'm not sure what the RFC says about this. Anil On Thu, 12 Feb 2004, 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 ? > > I use php 4.3.4 ... and Apache 2.x > > thanks > > > -- Linuxense Information Systems Pvt. Ltd., Trivandrum, India http://www.linuxense.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php