PHP Http post request parameters, php post request _ PHP Tutorial

Source: Internet
Author: User
The Http post request parameter in PHP and the php post request. The Http post request parameters in PHP. This article describes the Http post request parameters in php. the specific content is as follows: in WEB development, the information is basically all the Http POST request parameters in post and g php, and the php post request

This article introduces the Http post request parameters in PHP. the specific content is as follows:

In WEB development, the information is basically carried out in POST and GET requests and responses. because of its URL-based intuition, GET is easy to understand and can be concealed by POST requests, while ensuring security, it also brings difficulties for developers to simulate sending. In the next few blog posts, I will explain in detail several methods for PHP POST requests based on my notes and understanding. if any errors occur, please correct them.

HTTP protocol information is an important part of WEB development. understanding it can help us better understand BS interaction and help us understand WEB development at a lower level. HTTP is a simple, flexible, and convenient communication protocol. remember that it is a stateless protocol, that is, a non-memory protocol, each interaction is independent.

We can use the "network" panel of the browser development tool (IE's F12 Firefox FireBug, etc.) to view the HTTP header information.

Generally, HTTP header information is divided into three types: request information, response information, and interaction information (I think it is also a type of request information ).

1. request information:

When a website is accessed, the client sends a request message. This information does not contain data, but is only exposed to the server, prompting the server to return response information.

The format is two parts: request line and message header.

A. request line: method (request method) path (request site address) HTTP/version (Protocol/version information)

Common request methods include GET/POST/HEAD/OPTION.

B. message header:

Host (required): Host and port number. the default port number is 80.

Accept: type of the expected content to be received (image/gif text/html */*)

Accept-Encoding: the compression type to be received (gzip deflat)

Accept-Charset: the expected character set (UTF-8)

Accept-Language (zh-CN)

Cookie: the user's Cookie information

Connection: Connection control

User-Agent: client information

......

The following is a typical request header information:

GET index. php HTTP/1.1
Accept: text/html, application/xhtml + xml, application/xml; q = 0.9, image/webp, */*; q = 0.8
Accept-Encoding: gzip, deflate, sdch
Accept-Language: zh-CN, zh; q = 0.8
Cache-Control: max-age = 0
Connection: keep-alive
Cookie: SOHUHOMETAB = visit: 2; IPLOC = CN1407; SUV = 1510312046259910
Host: www.sohu.com
If-Modified-Since: Sat, 31 Oct 2015 12:45:22 GMT
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/537.36

2. Response Information

Server Return data

The response information is divided into three parts: the response body of the status line message header

A. status line: HTTP/version (Protocol/version information) status code status text (text description of status code)

There are five types of status codes:

1XX: indicates a temporary response. the requester must continue the operation.

2XX: indicates that the response is successful, and the server successfully responds to the request.

3XX: indicates redirection, which requires further operations by the requester.

4XX: indicates a client error and the server cannot respond normally.

5XX: indicates a server error and the server cannot respond normally.

For more information, see HTTP status codes.

B. message header:

Server: Server information

Content-Encoding: Data compression format

Content-Length: data Length

Content-Type: data Type

Cache-Control: Cache Control

Connection: Connection control

Date: Date information

Expires: returned data expiration information

Last-Modified: returns the Last modification time.

Set-Cookie: Set the Cookie information of the client.

......

C. response body

The returned page data is displayed as HTML documents on the page.

The following are common response messages:

HTTP/1.1 200 OK

Cache-Control: no-cache
Connection: close
Content-Encoding: gzip
Content-Length: 6947
Content-Type: text/html; charset = GBK
Date: Sat, 31 Oct 2015 13:30:11 GMT
Expires:-1
Pragma: no-cache
Proxy-Connection: keep-alive
Server: nginx/1.2.5
Set-Cookie: JSESSIONID = yiuug4yejhc1cdbzydoxlcpn; Path =/

3. interaction information

It is the request information that contains the request data. it is common in the registration of uploaded files.

The request body consists of three parts: the request body of the request line message header.

A. It is the same as the request line for request information

B. added data about the request body based on the request header.

Content-Type: Content Type of the uploaded information

Content-Length: the Length of the upload information.

......

C. request body:

That is, the specific data string of the request (name = xxx & passwork = xxx). of course, for the sake of security, the POST information is sometimes encrypted.

The following are typical request messages:

GET login. php HTTP/1.1
Host: passport.sohu.com
Accept: text/html, application/xhtml + xml, application/xml
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN, zh; q = 0.8
Cache-Control: max-age = 0
Connection: keep-alive
Content-Length: 166
Content-Type: application/x-www-form-urlencoded
Referer: http://mail.sohu.com/
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/537.36
Form Data
Domain = sohu.com & callback = Hangzhou & appid = 1113 & userid = FDFFDF % 40sohu.com & password = a3f4384c2bc44fa909ffd0ecc5fa8eb9 & persistentcookie = 0

Knowing what the browser sends to the server, it is not difficult to pretend to be a server in other ways.

In the next section, I will introduce how PHP and JS process the most basic URLs. when solving the GET request section, I will also simulate POST request preparation.

If you think this blog is helpful to you, you can recommend or like it. if you have any questions, you can leave a message below for a discussion. thank you.

This article introduces the Http post request parameters in PHP. The details are as follows...

Related Article

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.