|Lessons||PHP $_POST Variable|
In other words the $_POST variable is an array of variable names and values sent by the HTTP POST method. Please remember that, unlike a HTTP GET method, the information sent from a form with the POST method is not visible to anyone and it also does not have any limits on the amount of information to send.
<form action="phpPOST.php" method="post">
Name: <input type="text" name="name" /><br>
Occupation: <input type="text" name="occ" /><br>
<input type="submit" />
When you click the "Submit" button, the internet browser would take you to a URL looking something like:
Please note that, unlike, the HTTP GET method, the URL does not contain any form data.
The "phpPOST.php" file can now use the $_POST variable to catch the form data as shown below (notice that the names of the form fields will automatically be the ID keys in the $_POST array):
$name = $_POST["name"];
$occupation = $_POST["occ"];
The $_REQUEST Variable
One more PHP built in server-side variable, worth mentioning here, is the PHP $_REQUEST variable. This variable contains the contents of both $_GET and $_POST variables. Furthermore, this variable also contains the contents of the $_COOKIE variable. The PHP $_REQUEST variable can be used to get the result from form data sent with either the GET or the POST method. This is very helpful when we do not exactly know the method that is used to submit the form data. The usage of the $_REQUEST variable is very simple:
$name = $_REQUEST["name"];
$occupation = $_REQUEST["occ"];
Next: PHP Forms