php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2636 Incomprehensible Header() behaviour
Submitted: 1999-10-29 06:17 UTC Modified: 1999-10-29 16:34 UTC
From: dobosgy at netcity dot hu Assigned:
Status: Closed Package: Performance problem
PHP Version: 3.0.12 OS: Linux+Apache1.3.6
Private report: No CVE-ID: None
 [1999-10-29 06:17 UTC] dobosgy at netcity dot hu
Maybe a Netscape or a PHP3 bug?

This short code should echo "1" on every submit, because after
Header() the program shouldn't run and do anything.
On MSIE, lynx, and on 3 Amiga browsers it works fine, but on "all"
type and versions of Netscape it displays "2".

The problem can easily be solved by adding a parameter to the
$PHP_SELF like this:
Header("Location: $PHP_SELF?foo=bar");

The code:
<?
$var=1;
if (isset($butt)) {
	Header("Location: $PHP_SELF");
	$var=2;
}
?>
<html>
<head>
</head>
<body>
<form method="post" action="<?echo$PHP_SELF?>">
<?echo $var?>
<input type="submit" name="butt" value="OK">
</form>
</body>
</html>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-10-29 16:34 UTC] rasmus at cvs dot php dot net
This has nothing to do with PHP.  PHP scripts continue to run until they are finished unless you tell it to terminate when the client disappears.
See the Connection Handling chapter in the manual.  The fact that a 2 appears is a Netscape issue.  PHP will always try to send the 2 the way
you have written the script.  If you want the script to exit after the Header() call, add an exit; statement there.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 23:01:26 2024 UTC