One thing to be aware of, Location: /newpage.php will probably work with most browsers (I know it works with IE, Mozilla and Opera) but the spec requires an absolute path to the file you are redirecting to including protocol, server, path and file. As Wouter demonstrated you should always die() after a redirect request because it is just that, a request that the client is not required to follow.

Jason

Wouter van Vliet wrote:

Though no parse error, it can result in an notice about 'undefined index' ..
I'd prefer

<?php
if (isset($_COOKIE['pagename'])) {
        header('Location: /newpage.php');
        die;
};
?>

Taking care of three things:
        - No undifined index notice
        - the cookie can also have a value that evaluates to false
        - the 'die;' makes sure the script really ends .. sometimes, somehow for
some
          undefined reason it does not stop after a header..


Wouter



-> -----Oorspronkelijk bericht----- -> Van: Curt Zirzow [mailto:[EMAIL PROTECTED] -> Verzonden: zondag 24 augustus 2003 20:22 -> Aan: [EMAIL PROTECTED] -> Onderwerp: Re: [PHP] In need of a script -> -> -> * Thus wrote Stevie D Peele ([EMAIL PROTECTED]): -> > Heres what I wrote -- -> > -> > <?php -> > if ($_COOKIE['pagename']) -> > { -> > header('Location: http://www.net-riches.com/800x600.html'); -> > } -> > ?> -> > -> > and I got a parse error on line 4, but I do not see what is -> wrong on line -> > 4! -> -> There is no parse error in that code. -> -> Curt -> -- -> "I used to think I was indecisive, but now I'm not so sure." -> -> -- -> PHP General Mailing List (http://www.php.net/) -> To unsubscribe, visit: http://www.php.net/unsub.php




-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to