Advanced Search

Results 1 to 2 of 2

Thread: GET and POST methods

  1. #1
    Join Date
    Jul 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default GET and POST methods

    GET and POST methods
    Does anyone know exactly when to use the GET and when to use the POST methods, why and why not?


    Thanks in advance.
    Last edited by thetestingsite; 07-25-2008 at 05:14 PM. Reason: removed signature

  2. #2
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default

    If you submit a form such as this:

    Code:
    <form name="input" action="index.php"
    method="get">
    Username: 
    <input type="text" name="user">
    <input type="submit" value="Submit">
    </form>
    As you can see in the first line, the method is "get" meaning it will return this: "index.php?user=EnteredUserData&submit=Submit"

    This means if you want to set a variable to be one of those, use this:
    Code:
    $thename = $_GET['user'];
    echo $thename;
    The other mode, post, would be like this:
    Code:
    <form name="input" action="index.php"
    method="post">
    The url will be "index.php" after being submitted.

    To get the post variables, do something like this:
    Code:
    $theothername = $_POST['user'];
    echo $theothername;

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •