How does PHP use the Post method to get data from a form form? (code example)

Source: Internet
Author: User
Tags form post php form
During the development of our web site, we typically encounter actions related to the form of a PHP form. If PHP gets the form data with the post submission method, how does this work? If you have seen me "How does php get form form data by Get method?" "In this article, I believe you have a certain understanding of the method of getting form data for PHP $_get[] variables.

Then this article continues to give you a detailed introduction, how PHP through the Post method to obtain form form data.

The following is a specific code example:

1. Form form code (POST method Submission Form example):


Accessed through a browser, such as:


For example, we enter the name and age click Submit to the test.php file.

2. The test.php code is as follows (PHP gets post data):

<?phpheader ("Content-type:text/html;charset=utf-8");         Set the encoding?> welcome <?php echo $_post["fname"];?>!<br> you are <?php echo $_post["age";?>  years old.

Here we get form form data i.e. fname and age parameters via PHP $_post[] variables (refer to the second chapter of PHP 0 basic Getting Started Tutorial: PHP form), post-submission browser access results such as:

Notice here that no form form parameter appears in the link in the browser's address bar. That is, PHP gets the form information submitted by the Post method is completely not displayed in the Address bar. In Web Form design, most of the use of the post submission method, because it is more than the security of the Get method to submit the form is much higher, to avoid the leakage of sensitive information, and post send the amount of information is not limited. However, the page cannot be bookmarked because the variable is not displayed in the URL.

The above is about how PHP gets the post submission form data in a specific way. Have a certain reference value, hope to have a friend in need to help.

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.