note 34359 deleted from function.header by sniper

From: Date: Sun, 07 Sep 2003 21:49:34 +0000
Subject: note 34359 deleted from function.header by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-55660@lists.php.net to get a copy of this message
Note Submitter: lanny@style11.com ---- [Editor's note: to avoid this, just put the second header() call in a "else { }". ] If you omit the "exit;" call after each redirection header, they will essentially pile up, each execute, and you will be redirected to the location of the last one . I have noticed this common mistake among novice programmers. It is important to note that a header("Location:page") command does stop the rest of the page from processing. ** THE FOLLOWING CODE IS WRONG ** if ($x == 1) { header("Location: page1.php"); } header("Location:default.php"); ** SHOULD BE: ** if ($x == 1) { header("Location: page1.php"); exit; } header("Location:default.php"); exit;

« previous php.notes (#55660) next »