• Log in or sign up for an account here: https://www.sythe.org/login

[PHP] $_GET and $_POST

Raid500

Forum Addict
Joined
Feb 11, 2007
Sythe Gold
0
Messages
592
[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 :)
 
Runescape Gamblingrunescape gambling
Back
Top