From:             phpclass at oneroad dot com
Operating system: Windows 2000
PHP version:      4.3.4
PHP Bug Type:     Arrays related
Bug description:  dynamically generated form elements using name=foo[] submitted out 
of order

Description:
------------
When submitting a form with elements named using an array (e.g.:
name="foo[]"), the elements appear to be sent in the order in which the
elements are created, and not the order in which they appear in the form's
DOM tree. This can cause information to be sent in a mixed order when the
elements are created in a different order using DOM routines.

Reproduce code:
---------------
See http://www.oneroad.com/test/phpbug.phtml to run the code, or
http://www.oneroad.com/test/dombug.phps to view it (about 40 lines).



(This server is running 4.0.6, but I have reproduced the bug in 4.3.4 as
well.)



To reproduce:

(1) click "addrow"

(2) choose "1" in the first field, and type "abc" in the second field

(3) click "addrow"

(4) choose "2" in the first field, and type "def" in the second field

(5) change the first select field to "3".

(6) enter "abc" in the second field of the first row.

(7) click "go"



Expected result:
----------------
The $_GET array should contain the following:

Array

(

    [go] => go

    [field1] => Array

        (

            [0] => 3

            [1] => 2

        )



    [field2] => Array

        (

            [0] => abc

            [1] => def

        )



)

Actual result:
--------------
The $_GET array contained the following. Note the "field2" elements were
sent in the reverse order, because the element in the first row was
dynamically generated *after* the element in the second row.



Array

(

    [go] => go

    [field1] => Array

        (

            [0] => 3

            [1] => 2

        )



    [field2] => Array

        (

            [0] => def

            [1] => abc

        )



)

-- 
Edit bug report at http://bugs.php.net/?id=27631&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27631&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27631&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27631&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27631&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27631&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27631&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27631&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27631&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27631&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27631&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27631&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27631&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27631&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27631&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27631&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27631&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27631&r=float

Reply via email to