php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64672 POST variables not received by custom 404
Submitted: 2013-04-18 19:58 UTC Modified: 2015-04-03 19:10 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: grassgrr at gmail dot com Assigned:
Status: Open Package: Apache related
PHP Version: 5.4.14 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: grassgrr at gmail dot com
New email:
PHP Version: OS:

 

 [2013-04-18 19:58 UTC] grassgrr at gmail dot com
Description:
------------
I am attempting to catch variables submitted with a form via POST method on a 
custom 404 page on an apache server.

I have seen that IIS has a similar issue reported in bug #38094 that indicate the 
problem there is one of Microsoft's IIS but this issue is occurring on a LAMP 
stack so I am not completely sure if it is caused by PHP or a "feature" in Apache 
that is also in IIS.

Test script:
---------------
// note that this test script is similar to that of bug #38094

form.php:
<form method="post" action="missingpage.php">
  <input name="test" type="text" value="Meow">
  <input type="submit">
</form>

Custom 404 page:
404.php:
<?php print_r($GLOBALS); ?>

Expected result:
----------------
I would expect to see all variables that exist printed including one post 
variable named "test" with the value of "Meow" print on the custom 404 page.

Actual result:
--------------
All variables except for the Form variables print. Also $_SERVER['QUERY_STRING'] 
does not contain the query string used.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-03-05 20:42 UTC] narf at devilix dot net
It's not a PHP issue.

Apache just executes the 404.php in another process/thread (although this might be dependable on the PHP SAPI being used, not sure). That process couldn't possibly have those vars, because they were never sent to it.

You can use apache_note() to achieve what you want.

I'd say #38094 is the same issue.
 [2015-04-03 19:10 UTC] cmb@php.net
The provided 404.php test script is bogus, as $GLOBALS doesn't
contain any request variables as of PHP 5.4.0 (removal of
register_globals), anyway.

Furthermore the behavior depends on how the custom 404 page is
hooked. Using ErrorDocument with a fully qualified URL will cause a
redirection via the client, in which case the submitted data will
not be propagated.

FWIW, I tested the following 404.php (Windows 7, Apache 2.4.4,
mod_php, internal redirect):

    <?php
    
    var_dump($_SERVER['REQUEST_METHOD']);
    var_dump($_SERVER['QUERY_STRING']);
    var_dump(file_get_contents('php://input'));
    var_dump($_REQUEST);

The results after submitting form.php:

    string 'GET' (length=3)
    string '' (length=0)
    string 'test=Meow' (length=9)
    array (size=0)
      empty
      
These results appear to be buggy.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 06:01:28 2024 UTC