FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » $_POST, $_GET and $_REQUEST discarding duplicates
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: $_POST, $_GET and $_REQUEST discarding duplicates [message #170820 is a reply to message #170793] Mon, 29 November 2010 14:12 Go to previous message
matt[1] is currently offline  matt[1]
Messages: 40
Registered: September 2010
Karma:
Member
On Fri, 26 Nov 2010 15:07:33 -0800, James wrote:

> 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:
>
> Take the following string:
> myapp.php?a=12&a=12

This doesn't match...

> If I var dump $_REQUEST then or $_GET I get the following ///
>
> array(1) {
> ["verb"]=>
> string(8) "a"
> }

....this. Where's "verb" in your URI? Make sure you're posting real
examples. If this is real, it looks like something external is re-
arranging your request variables in ways that we cannot predict.

> 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?

Well, you have two options--you can either use the PHP-method of passing
multiple values to the same parameter name:

myapp.php?a[]=12&a[]=12

which will yield a two-element array, or if that's not an option, you can
parse the URI yourself using $_SERVER variables.

> I need to do this to pass a series of validation tests, functionally it
> has little impact. In an odd side to this if I alter the string to
> myapp.php?a=12&a=13 then var_dumping $_REQUEST results in a big fat null
> being returned. This I have been able to trap. But duplicate keys and
> values have got me stumped.

$_REQUEST should not === null in this case. Methinks something (in your
function library perhaps) is mucking with your variables before your
testing.

> Any clues?
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: setup of curl-multi: looping over a bunch of sites [how to adress the array]
Next Topic: ANNOUNCE: NHI1-0.10, PLMK-1.8 und libmsgque-4.8
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 02:14:20 GMT 2024

Total time taken to generate the page: 0.05180 seconds