Re: weird header() (bug may be)

From: Date: Thu, 12 Feb 2004 06:57:55 +0000
Subject: Re: weird header() (bug may be)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-177481@lists.php.net to get a copy of this message
--- adwinwijaya <adwinwijaya@yahoo.com.au> wrote: > 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 ? Nope. As others have pointed out, your Location header is improperly formed. However, your immediate problem is that, regardless of whether $foo == 'something', you *always* set the Location header to to_previous_page.php. So, even if you set it to to_another_page.php previously, you're overwriting it. Hope that helps. Chris ===== Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly Coming mid-2004 HTTP Developer's Handbook - Sams http://httphandbook.org/ PHP Community Site http://phpcommunity.org/

« previous php.general (#177481) next »