not parsing form data as multidimensional variables into $_POST

Bug #978107 reported by GodsMadClown
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
php5 (Ubuntu)
Invalid
Medium
Unassigned

Bug Description

I'm having trouble with form data getting into multidimensional data structures on the latest 12.4 beta. I also observe the same behavior on Suse Linux Enterprise, but not on CentOS. What am I missing?

I can define one explicitly, demonstrated with $test_array in the code examples below, however I can't get the post data to populate a similar structure.

The following basic form works as expected, with the input text data getting put into the variables text1 ... text4 in the $_POST array.

<?php

print_r($_POST);

$test_array = array ( 'test1' => array( 'test11' => 'test','test12' => 'test','test13' => array( 'test131' => 'test') ) );

print_r($test_array);
?>

<html>
<body>
<form action="samplepost.php" method="post">

First Name: <input type="text" id="fname" name="text1"></input>
<br/><br/>
Last name: <input type="text" id="lname" name="text2"></input>
<br/><br/>

text3: <input type="text" id="fname" name="text3"></input>
<br/><br/>
text4: <input type="text" id="lname" name="text4"></input>
<br/>

<br/>
<input name="submit1" type="submit" value="submit"></input>

</form>

</body>
</html>

but this doens't seem to work properly. After I submit a filled form, the first piece of form data gets populated into the $_POST araray, but all the other ones are always missing. I know the data is getting submitted, because the variable $inputdata gets populated in the example below. Why isn't that input getting parsed into $_POST?

<?php

$inputdata = file_get_contents( 'php://input' );
print_r($inputdata);
print_r($_POST);

$test_array = array ( 'test1' => array( 'test11' => 'test','test12' => 'test','test13' => array( 'test131' => 'test') ) );

print_r($test_array);
?>

<html>
<body>
<form action="samplepost.php" method="post">

First Name: <input type="text" id="fname" name="text1[fname]"></input>
<br/><br/>
Last name: <input type="text" id="lname" name="text1[lname]"></input>
<br/><br/>

text3: <input type="text" id="fname" name="text1[text3][text]"></input>
<br/><br/>
text4: <input type="text" id="lname" name="text1[text4][text]"></input>
<br/>

<br/>
<input name="submit1" type="submit" value="submit"></input>

</form>

</body>
</html>

GodsMadClown (wfindley)
no longer affects: php53 (Suse)
Revision history for this message
Clint Byrum (clint-fewbar) wrote :

I could not reproduce this on the latest 12.04 with PHP 5.3.10-1ubuntu3 using a basic libapache2-mod-php5 setup.

_POST comes out as

Array
(
    [text1] => Array
        (
            [fname] => a
            [lname] => b
            [text3] => Array
                (
                    [text] => c
                )

            [text4] => Array
                (
                    [text] => d
                )

        )

    [submit1] => submit
)

Given this script (combines the HTML with the result so you can keep trying values):

<html>
<body>
<?php

$inputdata = file_get_contents( 'php://input' );
print_r($inputdata);
echo '<pre>';
print_r($_POST);
echo '</pre>';

$test_array = array ( 'test1' => array( 'test11' => 'test','test12' => 'test','test13' => array( 'test131' => 'test') ) );
echo '<pre>';
var_export($test_array);
echo '</pre>';
?>
<form method="post">

First Name: <input type="text" id="fname" name="text1[fname]"></input>
<br/><br/>
Last name: <input type="text" id="lname" name="text1[lname]"></input>
<br/><br/>

text3: <input type="text" id="fname" name="text1[text3][text]"></input>
<br/><br/>
text4: <input type="text" id="lname" name="text1[text4][text]"></input>
<br/>

<br/>
<input name="submit1" type="submit" value="submit"></input>

</form>

</body>
</html>

Changed in php5 (Ubuntu):
importance: Undecided → Medium
Revision history for this message
GodsMadClown (wfindley) wrote : Re: [Bug 978107] Re: not parsing form data as multidimensional variables into $_POST

Yeah, I updated my test VM a few days ago and it's fixed. Go ahead and
close it.

On 4/20/2012 8:07 PM, Clint Byrum wrote:
> I could not reproduce this on the latest 12.04 with PHP 5.3.10-1ubuntu3
> using a basic libapache2-mod-php5 setup.
>
> _POST comes out as
>
> Array
> (
> [text1] => Array
> (
> [fname] => a
> [lname] => b
> [text3] => Array
> (
> [text] => c
> )
>
> [text4] => Array
> (
> [text] => d
> )
>
> )
>
> [submit1] => submit
> )
>
> Given this script (combines the HTML with the result so you can keep
> trying values):
>
> <html>
> <body>
> <?php
>
> $inputdata = file_get_contents( 'php://input' );
> print_r($inputdata);
> echo '<pre>';
> print_r($_POST);
> echo '</pre>';
>
> $test_array = array ( 'test1' => array( 'test11' => 'test','test12' => 'test','test13' => array( 'test131' => 'test') ) );
> echo '<pre>';
> var_export($test_array);
> echo '</pre>';
> ?>
> <form method="post">
>
> First Name:<input type="text" id="fname" name="text1[fname]"></input>
> <br/><br/>
> Last name:<input type="text" id="lname" name="text1[lname]"></input>
> <br/><br/>
>
> text3:<input type="text" id="fname" name="text1[text3][text]"></input>
> <br/><br/>
> text4:<input type="text" id="lname" name="text1[text4][text]"></input>
> <br/>
>
> <br/>
> <input name="submit1" type="submit" value="submit"></input>
>
> </form>
>
> </body>
> </html>
>
> ** Changed in: php5 (Ubuntu)
> Importance: Undecided => Medium
>

Revision history for this message
Clint Byrum (clint-fewbar) wrote :

Thanks for getting back on this one! Closing.

Changed in php5 (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.