How to get data in form through PHP post method? (code example)

藏色散人
Release: 2023-04-03 22:18:02
Original
15379 people have browsed it

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):

   form表单post方法示例 
名字:
年龄:
Copy after login

Access through browser, the effect is As shown below:

How to get data in form through PHP post method? (code example)

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):

 欢迎 !
你的年龄是 岁。
Copy after login

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:

How to get data in form through PHP post method? (code example)

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!