Results 1 to 2 of 2

Thread: Difference between $_POST and $_REQUEST

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2001
    Posts
    237

    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

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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
  •  



Click Here to Expand Forum to Full Width