PHP HTTP protocol Post request parameter _php instance

Source: Internet
Author: User
This article introduces the HTTP protocol post request parameters in PHP, as follows:

The information in web development is basically all in the post and get request and response, get because of its URL-based intuitive, easy to understand, can post requests because of their information hidden, in the security, but also to developers to send a simulation of the trouble. In the next few posts, I will combine my own notes and understanding to explain in detail several ways in which PHP makes post requests, such as errors.

HTTP protocol information is an important part of web development, and understanding it can help us understand the BS interactions more deeply, as well as enable us to understand web development from a much lower level. HTTP protocol is a simple and flexible communication protocol, and remember that it is a stateless protocol, that is, it is a non-memory protocol, each interaction is separate.

We can use the Browser development tool (ie F12 Firefox firebug, etc.) of the "Network" Panel to view the HTTP header information.

Generally, HTTP header information is divided into three categories: request information, response information, and interactive information (one that is personally considered to be a request for information).

1, Request information:

When accessing a Web site, the client sends out the request information, which does not carry data, but simply touches the server, prompting the server to return the response information.

Its format is two parts: the request line and the message header.

A. Request Line: Method (Request methods) path (request in-station address) Http/version (Protocol/version information)

Common request methods are get/post/head/option and so on.

B. Message header:

Host (required): hostname and port number, port number defaults to 80

Accept: Expected receive content type (image/gif text/html */*)

Accept-encoding: Compression type expected to receive (gzip Deflat)

Accept-charset: Expected received character set (Utf-8)

Accept-language (ZH-CN)

Cookie: 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-encoding:gzip, deflate, SDCH
Cookie:sohuhometab=visit:2; iploc=cn1407; suv=1510312046259910
If-modified-since:sat, Oct 12:45:22 GMT
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 returns data

Response information is divided into three parts: status line message header response body

A. Status line: Http/version (Protocol/version information) Status Code status text (text description of the status code)

There are 5 types of status codes:

1XX: Indicates a temporary response and requires the requestor to continue operation

2XX: Indicates a successful response and the server successfully responded to the request

3XX: Indicates redirection, requires further action by requester

4XX: Indicates a client error and the server is not responding properly

5XX: Indicates a server-side error and the server is not responding properly

For details, refer to: HTTP status code in detail

B. Message header:

Server: Servers information

Content-encoding: Data compression format

Content-length: Data length

Content-type: Data type

Cache-control: Cache Control

Connection: Connection Control

Date: Day Information

Expires: Returning expiration information for data

Last-modified: Returns the last modified time

Set-cookie: Setting Cookie information for clients

... ...

C. Response body

That is, the page data that is returned is displayed as an HTML document in the page.

The following are common response messages

http/1.1 OK

content-type:text/html; Charset=gbk
Date:sat, Oct 13:30:11 GMT

3, interactive information

Is the request information containing the request data is common in the user upload file registration, etc.

It is divided into three parts: Request line message header request body

A. Same as request line for request information

B. Adding data about the request body on the basis of the request header

Content-type: Content type for uploading information

Content-length: Length of uploaded information

... ...

C. Request Body:

That is, the requested specific data string (NAME=XXX&PASSWORK=XXX), of course, for security reasons, the post information is sometimes encrypted encoding.

The following is a typical request message:

GET login.php http/1.1
Accept-encoding:gzip, deflate
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

Understand what the browser is sending to the server, it is not difficult to disguise it as a server in other ways.

In the next section I will describe how PHP and JS handle the most basic URLs, as well as solving the GET Request section, and will also simulate the readiness to send a POST request.

If you think this blog is helpful to you, you can recommend or like, if you have any questions, you can also leave a comment, a discussion, thank you.

  • 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: 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.