Re: $_POST, $_GET and $_REQUEST discarding duplicates [message #170803 is a reply to message #170796] |
Sat, 27 November 2010 17:05 |
Luuk
Messages: 329 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 27-11-10 08:17, Thomas 'PointedEars' Lahn wrote:
> James wrote:
> ^^^^^
> James who?
>
>> I am working on an application and specifically validating user
>> input. The application can be sent input via POST or GET. One thing
>> I need to catch is duplicate variable names being passed:
>
> Those are not variable names, but parameter names. For variables there
> needs to be a *programming* language; (X)HTML is not.
>
>> Take the following string:
>> myapp.php?a=12&a=12
>>
>> If I var dump $_REQUEST then or $_GET I get the following ///
>>
>> array(1) {
>> ["verb"]=>
>> string(8) "a"
>> }
>>
>> The second instance of 'a' is dropped. If I was just using $_GET I
>> would simply pull $_SERVER['QUERY_STRING] up and pass it but for POST
>> data I don't believe I can do this. Can anybody suggest a function
>> that will allow me to find this duplicates in in POST and GET data?
>
> No.
>
> <… name="verb[]" …>
>
> will get you
>
> array(1) {
> ["verb"]=>
> array(…) {
> …
> }
> }
>
> It is a very old "problem", to be found discussed in a great many PHP FAQs.
> Please do search next time.
>
>
> PointedEars
Can you point us to these FAQ's?
When i tested, i got the following response:
test.php?a=12&a=12
response:
array(1) { ["a"]=> string(2) "12" }
so, OP seems to be right that the second parameter gets dropped.
but when i test with:
test.php?a=12&a=13
i get:
array(1) { ["a"]=> string(2) "13" }
so, in fact it looks more like the last parameters survives....
--
Luuk
|
|
|