PHP form-php $_post variable

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.