php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24007 register_globals + request arrays = missing register_global variables
Submitted: 2003-06-04 00:04 UTC Modified: 2003-06-14 10:09 UTC
From: gateschris at yahoo dot com Assigned: iliaa (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 4.3.2 OS: Linux version 2.2.19
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gateschris at yahoo dot com
New email:
PHP Version: OS:

 

 [2003-06-04 00:04 UTC] gateschris at yahoo dot com
when performing a post in a form, if the url contains a variable of the form name[key]=value, and php has register_globals enabled, the name/key is not registered.

example form:

<form enctype="multipart/form-data" method="post" action="test.php?name[key][key2]=value">
<input name="name[key][key3]" value="value" type="hidden">
</form>

example php:

<?
print_r($name);
?>

with register_globals on, this script will only remember the  name[key][key3] and not the name[key][key2], please note that i have not tested this script, its just a summary of what i have found in a much larger script, and ive already reverted back to an older version of php and im to lazy to try it on another machine.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-04 00:39 UTC] philip@php.net
Verified and related to bug #23454  Note that $_REQUEST works perfectly here...

<?php
if (@$_POST['action'] == 'submit') {
    print "<pre>";
    print_r(array('get'     => $_GET,
                  'post'    => $_POST,
                  'request' => $_REQUEST,
                  'foo'     => $foo));
} else {
?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>?foo[a][a]=a">
 <br><input type="text" name="foo[]" value="b">
 <br><input type="text" name="foo[a][b]" value="c">
 <br><input type="submit" name="submit" value="submit">
     <input type="hidden" name="action" value="submit">
</form>
<?php
}
?>

Outputs:

Array
(
    [get] => Array
        (
            [foo] => Array
                (
                    [a] => Array
                        (
                            [a] => a
                        )

                )

        )

    [post] => Array
        (
            [foo] => Array
                (
                    [0] => b
                    [a] => Array
                        (
                            [b] => c
                        )

                )

            [submit] => submit
            [action] => submit
        )

    [request] => Array
        (
            [foo] => Array
                (
                    [a] => Array
                        (
                            [a] => a
                            [b] => c
                        )

                    [0] => b
                )

            [submit] => submit
            [action] => submit
        )

    [foo] => Array
        (
            [0] => b
            [a] => Array
                (
                    [b] => c
                )

        )

)


 [2003-06-04 05:59 UTC] gateschris at yahoo dot com
Hi Philip, 
Yes, sorry i did not find that report before, but bug report #23454 
relates to a 4.3.2RC3-dev not 4.3.2 release version, and the bug 
report is closed, and iliaa@php.net mentions that they have 
patched the cvs on the 13 May (before the release version), so 
perhaps something is still wrong here, it seems like a serious 
bug in a release version to me. 
I will wait for the next point release (incase the patch was passed 
over this current release). 
Cheers,
 [2003-06-04 10:32 UTC] iliaa@php.net
The fix only fixed the _REQUEST, which is what you should be using. The register_global variables still have the same issue. I will look into this issue to see if it can be easily fixed, but I suspect there is a greater chance this will be marked won't fix.
 [2003-06-13 10:19 UTC] iliaa@php.net
You should either use the recommended _REQUEST super global or not create values with the same names in both POST & GET if you need to use register_globals.
 [2003-06-13 11:55 UTC] rasmus@php.net
I'm not ready to give up on this one.  This used to work and really should be fixed.
 [2003-06-14 10:09 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 21:01:36 2024 UTC