NYCPHP Meetup

NYPHP.org

[nycphp-talk] $_REQUEST: Bad Form?

bz-gmort at beezifies.com bz-gmort at beezifies.com
Fri Oct 12 15:43:43 EDT 2007


David Krings wrote:
> Brian D. wrote:
>> Can you define why it's bad form? When is it considered acceptable to 
>> use?
> 
> As mentioned above, I don't think it is "bad", but more dangerous in the 
> sense that you may not get anything when the server does not craft this 
> array. It is more that you need to know what to do with the data. I do 
> wonder if there ever is a situation where it is unknown if date comes 
> from POST or GET. Since you know what the variables are called and are 
> supposed to contain, isn't it reasonable to assume that  one also knows 
> how the data gets submitted?

If you setup an function to be called by multiple scripts(For example, 
pulling a list of matching auction lots based on search criteria) and 
you want to allow anyone to view your data or embed it on their site.

You might PREFER to demand a POST, but since your goal is to advertise 
the data demanding it would be a stupid thing to do - let the other 
people pull the data for display any way they want.

If your dealing with a large, complex application and your only changing 
one small part of it and have to complete it in a few hours.  You may 
have a GET coming from one section of the site, but you can't guarantee 
some other page isn't doing a POST.

All that said, though, it is remember that REQUEST is not just GET/POST, 
it's also COOKIE.  So if your logic counts on certain variables being 
empty if their not passed to the script, Than your better off using 
conditional logic to retrieve JUST the GET and the POST.

Mainly, the issue comes into play when you don't get to design/dictate 
the entire site OR you count on external web developers to call your app 
for some reason.




More information about the talk mailing list