php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33661 Header and _POST problem
Submitted: 2005-07-12 15:33 UTC Modified: 2005-07-20 01:00 UTC
Votes:5
Avg. Score:3.2 ± 1.3
Reproduced:2 of 3 (66.7%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: f dot hardy at origami-systems dot com Assigned:
Status: No Feedback Package: HTTP related
PHP Version: 5.0.4 OS: freebsd 4.10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: f dot hardy at origami-systems dot com
New email:
PHP Version: OS:

 

 [2005-07-12 15:33 UTC] f dot hardy at origami-systems dot com
Description:
------------
I have a problem with $_POST and the header() function.
If I make a test on $_POST, my 404 http header is replaced by a 2OO OK header.
If I make a test on $_GET (with a get action in html form), or an another variable, I receive the 404 http header.



Reproduce code:
---------------
<?php
if (isset($_POST['test']) == true)
{
	header("HTTP/1.1 404 Not Found", true);
	die();
}
else
{
?>
<form method="post">
	<input type="text" name="test" value="" />
	<input type="submit" name="modify" value="Modify" />
</form>
<?php
}
?>

Expected result:
----------------
A 404 HTTP header in response.

Actual result:
--------------
A 200 OK HTTP header in response.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-12 16:03 UTC] rasmus@php.net
Are you sure?  I tested your code under both PHP 4.4 and 5.1 and it works nicely.  With a request like:

POST /abc.php HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: UTF-8,*
Keep-Alive: 300
Connection: keep-alive
Referer: http://localhost/abc.php
Content-Type: application/x-www-form-urlencoded
Content-Length: 19
test=&modify=Modify

I get back:

HTTP/1.x 404 Not Found
Date: Tue, 12 Jul 2005 13:59:21 GMT
Server: Apache/1.3.33 (Debian GNU/Linux) PHP/5.1.0-dev
X-Powered-By: PHP/5.1.0-dev
Content-Type: text/html; charset=utf-8
Keep-Alive: timeout=1, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked

Of course, there is no body to the 404 response, because you are not sending any.  So how exactly did you check that you were getting a 200 back on the POST request?
 [2005-07-12 16:04 UTC] joerg@php.net
Whats happend after you add the missing action tag ot the form?

 [2005-07-12 16:12 UTC] rasmus@php.net
You don't need an action there.  But if you set it explicitly it doesn't change the result.
 [2005-07-12 16:16 UTC] f dot hardy at origami-systems dot com
I am using firefox 1.0.4 on freebsd.

Response Headers - http://xxx.local/update.php

Date: Tue, 12 Jul 2005 14:14:53 GMT
Server: Apache/1.3.33 (Unix) PHP/5.0.4
X-Powered-By: PHP/5.0.4
Keep-Alive: timeout=15, max=96
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html

200 OK
 [2005-07-12 16:47 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-07-20 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2007-08-01 05:50 UTC] shellva_s at yahoo dot co dot in
hi

   I want to know the thing that how to avoid the form field values lose when the page reloaded or refreshed.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jan 16 18:01:29 2025 UTC