In the process of website development, we usually encounter related operations on php form forms. For example, if PHP obtains form data with post submission method, how to operate it? If you have read my [How does PHP obtain form form data through the get method?】In this article, I believe everyone already has a certain understanding of the method ofphp $_GET[] variableto obtain form data.
Then this article will continue to give you a detailed introduction to how PHP obtains form form data through the post method.
There are specific code examples below:
1. Form form code (post method submission form example):
Access through browser, the effect is As shown below:
As shown above, we enter the name and age and click submit to the test.php file.
2. The test.php code is as follows (php gets post data):
欢迎 !
你的年龄是 岁。
Here we get the form through thePHP $_POST[] variableThe form data is the fname and age parameters (recommended to refer to Chapter 2 ofPHP Zero Basics Introductory Tutorial:PHP Form). After submission, the browser access result is as follows:
You can notice here that no form parameters appear in the link in the browser address bar. That is to say, the form information submitted by PHP obtained through the post method is not displayed at all in the address bar. In web form design, most people use the post submission method because it is much more secure than the get method for submitting forms, can avoid the leakage of sensitive information, and there is no limit to the amount of information sent by post. But since the variable does not appear in the URL, the page cannot be bookmarked.
The above content is about the specific method and function of PHP to obtain post submission form data. It has certain reference value and I hope it will be helpful to friends in need.
The above is the detailed content of How to get data in form through PHP post method? (code example). For more information, please follow other related articles on the PHP Chinese website!