|
-
Aug 1st, 2006, 09:45 PM
#1
Thread Starter
Addicted Member
Difference between $_POST and $_REQUEST
hi.. I just found out that using $_POST to access variables from a form can also be done using $_REQUEST that used to be used to access variables NOT from a form.
So, if I have a form with a textbox named "username", after the user press the submit button, I can access the variable username using $_POST['username'] and $_REQUEST['username'], they both will result the same.
But if I use a link like this "login.php?user=$username", you can only access the variable user using $_REQUEST['username'].
My question is, if to process forms they're both the same, why should I use $_POST instead of $_REQUEST? Why not just use $_REQUEST all the time? Does it have anything to do with register global?
thanks
-
Aug 2nd, 2006, 01:01 AM
#2
Re: Difference between $_POST and $_REQUEST
$_REQUEST contains the aggregate contents of $_POST, $_GET, and $_COOKIE. You can use it if you don't give a stuff about where the variable comes from.
You should however still honour the semantic difference between GET and POST. GET is used for one way query requests - extracting data. POST is used for modifying data.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|