Php$_post Variable
In PHP, the predefined $_post variables are used to collect values from the form method= "POST".
$_post variable
The predefined $_post variables are used to collect values from the form method= "POST".
The information sent from a form with a POST method is not visible to anyone (not displayed in the browser's address bar), and there is no limit to the amount of information sent.
Note: However, by default, the maximum number of messages sent by the POST method is 8 MB (this can be changed by setting the post_max_size in the php.ini file).
Instance
The form.html file code is as follows:
name : <input type= "text" name= "fname" > Age : <input type= "text" Name= "ages" ><input type= "Submit" value= "Submit" ></form></body></ Html>
When the user clicks the Submit button, the URL resembles the following:
http://www.runoob.com/welcome.php
The "welcome.php" file can now collect form data through the $_post variable (note that the name of the form field automatically becomes the key in the $_post array):
Echo $_post ["FName"];?>!<br>echo$_post["Age"];?> .
Through browser access the demo is as follows:
When to use method= "post"?
The information sent from a form with a POST method is not visible to anyone, and there is no limit to the amount of information sent.
However, because the variable is not displayed in the URL, the page cannot be bookmarked.
PHP $_request variables
The predefined $_request variables contain the contents of $_get, $_post, and $_cookie.
The $_request variable can be used to collect form data sent through the GET and POST methods.
Instance
You can change the "welcome.php" file to the following code, which can accept data such as $_get, $_post, and so on.
Echo $_request ["FName"];?>!<br>echo$_request["Age"];?> .
PHP form-php $_post variable