[PHP] $_GET and $_POST

Discussion in 'Archives' started by Raid500, Aug 16, 2009.

[PHP] $_GET and $_POST
  1. Unread #1 - Aug 16, 2009 at 9:04 PM
  2. Raid500
    Joined:
    Feb 11, 2007
    Posts:
    592
    Referrals:
    1
    Sythe Gold:
    0

    Raid500 Forum Addict

    [PHP] $_GET and $_POST

    $_GET and $_POST Tutorial.​


    What is the difference?
    It's hard to explain, but $_GET has something to do with how the url will change and $_POST doesn't. (If someone has a better way of explaining feel free to tell me :)


    What is $_GET?
    $_GET is a way to get information from 1 page to another.

    Lets look at an example..
    Code:
    <form action="login.php" method="get">
    Username: <input type="text" name="username" />
    Password: <input type="text" name="pass" />
    <input type="submit" />
    </form>
    
    Above is a html script that would make a basic form. As you can see, the form action="login.php" is where the form will be submitted to. The url would then look something like this:
    http://www.sythe.org/login.php?username=raid&pass=wonttellyoumypwlol

    Then you could make a page that displays the info on login.php, as so:
    Code:
    <?php //php tag
    $username = $_GET['username']; //variable to display the username
    echo "Welcome $username"; //displays the username here
    ?> //php tag
    

    What is $_POST?
    $_POST displays information on another site without change the url. Basically, we can use the same code as above, but change a few things..

    Code:
    <form action="login.php" method="post">
    Username: <input type="text" name="username" />
    Password: <input type="text" name="pass" />
    <input type="submit" />
    </form>
    
    Only 1 changed, the method="post" instead of get. Once you input the information the url will stay http://www.rscproject.com/login.php without the extra stuff at the end.





    So basically $_GET and $_POST are almost the same things.



    Hope it helped,
    Raid





    AS ALWAYS, REPORT ANY ERRORS TO ME :)
     
< Connect Mysql and PHP | Selling santa hat >

Users viewing this thread
1 guest


 
 
Adblock breaks this site