Re: $_POST vs $_REQUEST
| From: | shiplu | Date: | Mon, 22 Feb 2010 20:54:13 +0000 |
| Subject: | Re: $_POST vs $_REQUEST | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-302259@lists.php.net to get a copy of this message | ||
On Tue, Feb 23, 2010 at 2:39 AM, Slack-Moehrle
<mailinglists@mailnewsrss.com> wrote:
> Hi All,
>
> I have Forms that I submit for processing. I have seen examples of people using either $_POST
> or $_REQUEST.
>
> When would I choose one over the other?
>
> Also, I see examples of these being used with and without the single quotes
>
> Like:
>
> $_POST[j_orderValue]
> or
> $_POST['j_orderValue']
>
> Single quotes is best, correct to prevent sql injection?
You must use quote. either single or double. It wont affect sql injection.
Sanitize your data before using it in any sql.
$_REQUEST['var'] means a variable var was passed in http request.
$_POST['var'] means a post variable var was passed in http request.
A get or cookie variable var2 will set $_REQUEST['var2'].
When you are strictly expecting a Post variable 'var3' use
$_POST['var3'], not $_REQEUST['var3'].
This is because a $_GET['var3'] will make $_REQEUST['var3'] available
to you which is not what you want.
Correct me if I am wrong.
--
Shiplu Mokaddim
My talks, http://talk.cmyweb.net
Follow me, http://twitter.com/shiplu
SUST Programmers, http://groups.google.com/group/p2psust
Innovation distinguishes bet ... ... (ask Steve Jobs the rest)