PHP post data and request data. PHP post data and request data $ _ POST variable (array) is similar to $ _ GET variable (array ), $ _ POST indicates the PHP post data and request data submitted by the page through the post method.
PHP post data and request data
$ _ POST variable (array)
Similar to the $ _ GET variable (array), $ _ POST represents an array formed by the data submitted by the page through the post method.
Post submits data, usually in the following form:
The function is: after the user fills in the form data and submits it, the data will be sent (submitted) to the page abc. php can also be understood as "opening" the webpage (abc. php), it can also be understood as "request" the webpage (abc. php)
$ V1 = $ _ POST ['uname']; // double quotation marks can also be used for single quotes. essentially, a string is actually the key name (subscript) of an array)
$ V2 = $ _ POST ['upswd ']; // The key name must be exactly the same as the name at the time of submission (case sensitive)
// You can also display all post data:
Var_dum ($ _ POST)
?>
The form of receiving post data is: (in the abc. php webpage)
Generally, form forms in webpages are usually post, and get is usually reflected in the other three forms.
$ _ REQUEST variable (array)
The $ _ REQUEST array is not an independent data source, but the "sum" of $ POST data and $ _ GET data"
That is, the $ _ REQUEST array contains all $ _ POST data and $ _ GET data, which are automatically stored in the system.
Generally, $ _ POST and $ _ GET data do not "appear at the same time", and the $ _ REQUEST array represents one of them.
When both get and post data are submitted:
In this case, there is usually only one html syntax, as shown below:
Then, the uName and uPswd data are submitted to abc. php in post mode.
At the same time, data a = 5 and B = 10 are submitted to abc. php in get mode.
Get data in the page as follows:
$ V1 = $ _ GET ['A'];
$ V2 = $ _ GET ['B];
In this way, the post data is obtained:
$ V3 = $ _ POST ['uname'];
$ V4 = $ _ POST ['upswd '];
However, you can also obtain all the data as follows:
$ V1 = $ _ REQUEST ['A'];
$ V2 = $ _ REQUEST ['B];
$ V3 = $ _ REQUEST ['uname'];
$ V4 = $ _ REQUEST ['upswd ']
When both get data and post data are submitted with duplicate names:
WKioL1ZB0guxMIlkAABmi-th574335.jpg
1: try to avoid duplicate names
2: If the name is duplicated, $ _ REQUEST will only record (store) one of the data (either get data or post data)
3: Which record is determined by a setting in php. ini.
Request_order = "GP"; // This is the default value. G indicates GET, and P indicates POST.
The meaning is: First Store GET data and then store POST data
It can be seen that if the name is repeated, the POST data will overwrite the GET data.
Change to: request_order = "PG". The order is reverse .....
Note: $ _ REQUEST, $ _ GET, and $ _ POST data are independent of each other!
$ _ SERVER variable (array)
This variable stores some request information or setting information of the server or client. There are many data items, and different servers and different request pages may have different data items.
Commonly used:
REMOTE_ADDR user's IP address
SERVER_ADDR server IP address
SERVER_NAME server name (host name)
The absolute path of the DOCUMENT_ROOT site (in fact, it is the DocumentRoot in the host settings)
PHP_SELF file path of the current webpage
QUEER_STRING indicates the overall font string of a get request, similar to the following:
Http://www.abc.com/abc.php? A = 5 & B = 10 "a = 5 & B = 10" in the link"
Output all items (possibly different from each server): 9000000000000000
The post data of requests PHP and the request data $ _ POST variable (array) are similar to the $ _ GET variable (array ), $ _ POST indicates the data submitted by the page through post...