lszanto Posted January 8, 2007 Share Posted January 8, 2007 When writing scripts do you prefrer to use $_REQUEST so that you can pick up both post and get or do you use the individual $_GET and $_POST depending on how you sent the variables, I personally just use $_POST or $_GET but I wanted to here what everybody else thinks. Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/ Share on other sites More sharing options...
neylitalo Posted January 8, 2007 Share Posted January 8, 2007 I try to use $_REQUEST when I can remember to use it, but I've gotten in the habit of using the individual variables. The framework we use at work handles all the server-client communications, too, so I don't actually have to deal with them. Just a side note: $_REQUEST contains $_POST, $_GET, $_FILES, and $_COOKIE. Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-155517 Share on other sites More sharing options...
fert Posted January 8, 2007 Share Posted January 8, 2007 $_POST and $_GET Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-155561 Share on other sites More sharing options...
redbullmarky Posted January 8, 2007 Share Posted January 8, 2007 $_POST and $_GET too. aside from the security, it makes it easier from a debugging point of view as I know exactly where i'm extracting the variables from. Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-155699 Share on other sites More sharing options...
Daniel0 Posted January 8, 2007 Share Posted January 8, 2007 $_POST and $_GET. I never use $_REQUEST as it includes $_COOKIE as well which is not what I want.Edit: Could somebody add a poll to the topic, please? Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-155725 Share on other sites More sharing options...
neylitalo Posted January 8, 2007 Share Posted January 8, 2007 Poll added, although I'm not sure how much value it's going to contribute. :) Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-156104 Share on other sites More sharing options...
Daniel0 Posted January 8, 2007 Share Posted January 8, 2007 [quote author=neylitalo link=topic=121453.msg500065#msg500065 date=1168294187]Poll added, although I'm not sure how much value it's going to contribute. :)[/quote]Well, it's just that it makes more sense to have a poll in the poll forum. Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-156134 Share on other sites More sharing options...
sloshire1 Posted January 8, 2007 Share Posted January 8, 2007 It depends on how the form is going to be used. I typically try to use $_POST and $_GET when I know who will be submitting data to the script. I will only use $_REQUEST if I don't know the method the submitting form is using. Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-156139 Share on other sites More sharing options...
Daniel0 Posted January 8, 2007 Share Posted January 8, 2007 [code]$input = array_merge($_POST,$_GET);[/code] ;) Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-156152 Share on other sites More sharing options...
sloshire1 Posted January 8, 2007 Share Posted January 8, 2007 Thanks for the tip, I will use that.[quote author=Daniel0 link=topic=121453.msg500114#msg500114 date=1168296913][code]$input = array_merge($_POST,$_GET);[/code] ;)[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-156158 Share on other sites More sharing options...
lszanto Posted January 10, 2007 Author Share Posted January 10, 2007 [quote author=Daniel0 link=topic=121453.msg500114#msg500114 date=1168296913][code]$input = array_merge($_POST,$_GET);[/code] ;)[/quote]It might sound dumb but does that mean you can do $input['varname'] to retrieve the variables send? Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-157127 Share on other sites More sharing options...
Daniel0 Posted January 10, 2007 Share Posted January 10, 2007 Yes. Like you would with $_POST['varname'] and $_GET['varname']. Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-157601 Share on other sites More sharing options...
redbullmarky Posted January 10, 2007 Share Posted January 10, 2007 you do need to be careful though. IMO, $_POST and $_GET are seperate for a reason - so that you get 100% control over what should be read from where.Daniel's example does what $_REQUEST does, but I dont like the idea that someone could come along and drop something in the URL ($_GET) that should be submitted via a form ($_POST).Also from a debugging point of view, as i mentioned before, at least if your look at $_POST and $_GET in your code, you think "ahh, that's coming from the form and that's coming from the URL" whereas with $_REQUEST or the above example, you're kinda stuck. Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-157626 Share on other sites More sharing options...
Daniel0 Posted January 10, 2007 Share Posted January 10, 2007 Just a correction... $_REQUEST includes cookies as well, so it's not entirely the same.In my opinion it doesn't really matter if the data comes from a FORM or GET request. Both are controlled by the user anyways. Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-157724 Share on other sites More sharing options...
lucasl Posted January 11, 2007 Share Posted January 11, 2007 Post and get, I don't really know why. Its just the way I learn't. Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-158073 Share on other sites More sharing options...
ober Posted January 12, 2007 Share Posted January 12, 2007 Depends... I use $_REQUEST from time to time, but most times I want to know where stuff is coming from. Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-159274 Share on other sites More sharing options...
Ninjakreborn Posted January 12, 2007 Share Posted January 12, 2007 I never have used request before, it's always been post, get, cookie, session.I also agree with the comments made my redbullmarky on this one, I think it makes them easier to debug, and if I came into a program, and saw request, It would take an extra 5-10 minutes getting oriented, instead of one with post/get where I know what is going on first thing. Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-159280 Share on other sites More sharing options...
Philip Posted January 15, 2007 Share Posted January 15, 2007 I still use the individual ones... I don't think I'll ever change. You never know. ;) Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-160936 Share on other sites More sharing options...
JayBachatero Posted January 19, 2007 Share Posted January 19, 2007 Well I got in the habit of doing things the SMF way so I use $_REQUEST and $_POST. $_COOKIE is taken out of $_REQUEST though. Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-164446 Share on other sites More sharing options...
artacus Posted January 25, 2007 Share Posted January 25, 2007 I use $_REQUEST. As for the "be careful, it contains $_COOKIE" warning, everything in $_REQUEST should be suspect. $_GET or $_POST is just as easy to spoof, using cross-site scripting, as messing with $_COOKIE. Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-168733 Share on other sites More sharing options...
Cep Posted January 25, 2007 Share Posted January 25, 2007 [quote author=redbullmarky link=topic=121453.msg499656#msg499656 date=1168252101]$_POST and $_GET too. aside from the security, it makes it easier from a debugging point of view as I know exactly where i'm extracting the variables from.[/quote]This is the reason I do it :) Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-168824 Share on other sites More sharing options...
rantsh Posted January 31, 2007 Share Posted January 31, 2007 $_REQUEST brings you A LOT of security issues corrected with the register globals parameter Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-173259 Share on other sites More sharing options...
neylitalo Posted February 1, 2007 Share Posted February 1, 2007 They're similar, but not the same thing. register_globals is much more serious in that you can over-ride an internal variable simply by putting one in the URL or POST data with the same name and the contents you'd like it to have. $_REQUEST just means that different input sources can over-ride other input sources, not internal variables. Quote Link to comment https://forums.phpfreaks.com/topic/33286-_post-and-_get-or-_request/#findComment-174600 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.