Maybe this would help:
PHP global variable: $_POST
* $_POST is a global variable which holds the value of "index variable(s)" (this is just a name created by me to point out what I mean)
* This "index variable", refers to the name of the html tag -- which the user puts his data. For example the textfield in html:
Code:
<form method="post" action="example.php">
<input type="text" name="firstname" />
</form>
in this example, in my form, the method is post so that I can use the global variable $_POST. Inside my form is a textfield which name is firstname. In this case, the name of the textfield becomes an index of $_POST.
* By the way, if you write $variable = $_POST['firstname'], $_POST['firstname'] is a value. In contrast, if you write $_POST['firstname'] = "michael" , $_POST['firstname'] is a variable. A variable in the right hand side of an equal sign is a value, while a variable in the left hand side of an equal sign is a storage.
* I forgot, $_POST is an array while $_POST['firstname'] is a variable.
PHP global variable: $_GET
* Much more the same as $_POST.
* The method of your form must be get (method="get") in order to use the global variable $_GET. (Remember: From the previous example, we use post as the value of our method because we want to use the global variable $_POST)
* How to use $_GET:
Code:
<form method="get" action="example.php">
<input type="text" name="firstname" />
</form>
same as $_POST, firstname will become an index of $_GET. But, unlike $_POST, you can see firstname in the url. For example, if I submitted this form, the url will be:
Code:
localhost/example.php?firstname=michael
* $_GET is also used to get the variable of a url. Refer to the url above, firstname is what I mean the variable. Remember that after the question mark (?) of a url is a variable. You can make multiple variables in a url, You just add the "&" simbol after the value of the previous variable. For example:
Code:
localhost/example.php?firstname=michael&lastname=jordan&number=23
firstname, lastname, and number are all variables of the url. You can use those variables as indeces of $_GET to get their values
Code:
$_GET['firstname'] // the value of this is michael
$_GET['lastname'] // the value of this is jordan
$_GET['number'] // the value of this is 23
Refer to this site:
www.w3schools.com
www.thornwebdesign.de
Bookmarks