ID:               27631
 User updated by:  phpclass at oneroad dot com
 Reported By:      phpclass at oneroad dot com
 Status:           Open
 Bug Type:         Arrays related
 Operating System: Windows 2000
 PHP Version:      4.3.4
 New Comment:

Ah...I'm sorry. I should have tested just a little more before
submitting the test case, and I should have talked about browsers.



The test case reproduces only in Mozilla (I tested with 1.6). It does
NOT reproduce with MSIE 6. And just to make matters more complicated,
Opera 7.23 has a whole different problem (it doesn't show field1 at
all).



With three different browsers, there are three different outcomes.
Given that, there's no clear way to determine whether the bug I've
reported is the result of a browser issue, or a PHP issue.



At first glance, it seems that each browser is submitting the http data
in varying orders, and this is most likely something that PHP can't do
anything about, but this conclusion would be better coming from someone
with more knowledge of how this code works in PHP.


Previous Comments:
------------------------------------------------------------------------

[2004-03-17 21:45:28] phpclass at oneroad dot com

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 this bug report at http://bugs.php.net/?id=27631&edit=1

Reply via email to