Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to get form data by PHP

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "how to get form data from PHP". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to get form data from PHP" can help you solve the problem.

PHP access form data methods are: 1, the use of the predefined variable "$_ GET", you can get the data submitted by the GET method; 2, the use of the predefined variable "$_ POST", you can get the data submitted by the POST method; 3, the use of the predefined variable "$_ REQUEST", GET and POST methods to submit data can be obtained.

Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

1. Use the predefined variable $_ GET to get the data submitted by the GET method (the form form needs to be set to method= "get")

During the development of the program, because the data submitted by the GET method is attached to the URL and sent, the information of the type "parameters passed by the URL+ user" will be displayed in the address bar of URL, as follows:

Http://url?name1=value1&name2=value2...

Name1 and name2 are the names of the form elements (with the name attribute set for the form elements), and value1 and value2 are the values of the form elements. Use "?" between url and form elements. Separated, while multiple form elements are separated by a "&". Each form element is formatted as "name=value" and is fixed.

Let's add the form of the user.html file and look at the address bar of URL

The predefined variable $_ GET can be used directly in the user.php file to get the data. The $_ GET global variable is an associative array whose key name is the value of the form element name, and the value of the array is the value of the corresponding form. (note only if the parameters in URL can be obtained using $_ GET. )

You can use $_ GET [key name] to get the values of each form element one by one:

2. Use the predefined variable $_ POST to get the data submitted by the POST method (the form form needs to be set to method= "post")

The post method does not depend on URL and does not display the passed parameter values in the address bar.

The $_ POST global variable is also an associative array. The key name of the array is the value of the form element name, and the value of the array is the value of the corresponding form.

3. The data submitted using the predefined variable $_ REQUEST,GET and the POST method can be obtained.

The $_ REQUEST global variable is an array containing $_ POST, $_ GET, and $_ COOKIE, and the array structure is similar to $_ POST and $_ GET.

That's all for "how to get form data from PHP". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report