View Full Version : GET and POST methods

07-25-2008, 04:29 PM
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.

07-25-2008, 11:02 PM
If you submit a form such as this:

<form name="input" action="index.php"
<input type="text" name="user">
<input type="submit" value="Submit">

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:

$thename = $_GET['user'];
echo $thename;

The other mode, post, would be like this:

<form name="input" action="index.php"
The url will be "index.php" after being submitted.

To get the post variables, do something like this:

$theothername = $_POST['user'];
echo $theothername;