search
HomeBackend DevelopmentPHP TutorialHttp protocol post request parameters in PHP, php protocol post request_PHP tutorial

Http protocol post request parameters in PHP, php protocol post request

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

In WEB development, information is basically processed in POST and GET requests and responses. GET is easy for us to understand because it is intuitive based on URLs, but POST requests are safe because of the concealment of information. Those who simulated sending caused trouble. In the next few blog posts, I will combine my own notes and understanding to explain in detail several methods of PHP making POST requests. If there are any errors, please correct me.

HTTP protocol information is an important content in WEB development. Understanding it can help us understand BS interaction more deeply, and also help us understand WEB development from a lower level. The HTTP protocol is a simple, flexible and convenient communication protocol, and it should be remembered that it is a stateless protocol, that is, it is a memoryless protocol, and each interaction is separate.

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

Generally, HTTP header information is divided into three categories: request information, response information and interactive information (personally think it is also a type of request information).

1, request information:

When visiting a website, the client will send out request information. This information does not contain data, but simply contacts the server, prompting the server to return response information.

Its 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, etc.

B. Message header:

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

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

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

Accept-Charset: The character set expected to be received (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:

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 returns data

The response information is divided into three parts: status line, message header, and response body

A. Status line: HTTP/version (protocol/version information) status code status text (text description of the status code)

There are 5 categories of status codes:

1XX: Indicates a temporary response and requires the requester to continue operating

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

3XX: Indicates redirection and requires further operation from the requester

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

5XX: Indicates a server-side error and the server cannot respond normally

For specific information, please refer to: Detailed explanation of 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: Expiration information of returned data

Last-Modified: Returns the last modified time

Set-Cookie: Set the client’s cookie information

 ... ...

C. Response text

 That is, the returned page data is displayed in the form of HTML document 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, interactive information

It is the request information that contains the request data. It is commonly used when users upload files, register, etc.

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

A. Same as the request line requesting information

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

Content-Type: Content type of uploaded information

Content-Length: The length of the uploaded information

 ... ...

C. Request text:

That is the specific data string requested (name=xxx&passwork=xxx). Of course, for security reasons, the POST information is sometimes encrypted and encoded.

The following is a typical request message:

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=passport20008375022711697966_cb1446298206568&appid=1113&userid=FDFFDF@sohu.com&password=a3f4384c2bc44fa909ffd0ecc5fa8eb9&persistentcookie=0

Now that you understand what the browser sends to the server, it is not difficult to use other methods to disguise yourself as a server.

In the next section, I will introduce how PHP and JS handle the most basic URLs. While solving the GET request part, I will also be fully prepared to simulate sending a POST request.

If you think this blog post is helpful to you, you can recommend it or like it. If you have any questions, you can also leave a message below and let’s discuss it together. Thank you.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1067301.htmlTechArticleHttp protocol post request parameters in PHP, php protocol post request This article introduces the Http protocol post request parameters in PHP, The specific content is as follows: Information in WEB development is basically all in POST and G...
Statement
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
如何解决Java开发中的HTTP请求连接被拒绝问题如何解决Java开发中的HTTP请求连接被拒绝问题Jun 29, 2023 pm 02:29 PM

如何解决Java开发中的HTTP请求连接被拒绝问题在进行Java开发中,经常会遇到HTTP请求连接被拒绝的问题。这种问题的出现可能是由于服务器端限制了访问权限,或是网络防火墙阻止了HTTP请求的访问。解决这个问题需要对代码和环境进行一些调整。本文将介绍几种常见的解决方法。检查网络连接和服务器状态首先,确认你的网络连接是正常的,可以尝试访问其他的网站或服务,看

PHP使用HTTP请求发送邮件的方法PHP使用HTTP请求发送邮件的方法May 21, 2023 pm 07:10 PM

PHP是一种广泛使用的编程语言,其中一个常见的应用就是发送电子邮件。在这篇文章中,我们将讨论如何使用HTTP请求发送邮件。我们将从以下几个方面来介绍这个主题:什么是HTTP请求发送邮件的基本原理使用PHP发送HTTP请求发送邮件的示例代码什么是HTTP请求HTTP请求是指发送到web服务器的请求,以获取web资源。HTTP是一种协议,用于在web浏览器和we

Go发起HTTP2.0请求流程分析(后篇)——标头压缩Go发起HTTP2.0请求流程分析(后篇)——标头压缩Jul 21, 2023 pm 04:30 PM

HPACK 压缩上下文包含一个静态表和一个动态表:静态表在规范中定义,并提供了一个包含所有连接都可能使用的常用 HTTP 标头字段的列表;动态表最初为空,将根据在特定连接内交换的值进行更新。

Go发起HTTP2.0请求流程分析(中篇)——数据帧&流控制Go发起HTTP2.0请求流程分析(中篇)——数据帧&流控制Jul 21, 2023 pm 04:10 PM

HTTP2通信的最小单位是数据帧,每一个帧都包含两部分:帧头和Payload。不同数据流的帧可以交错发送(同一个数据流的帧必须顺序发送),然后再根据每个帧头的数据流标识符重新组装。

Java API 开发中使用 Apache HttpClient 进行 HTTP 请求Java API 开发中使用 Apache HttpClient 进行 HTTP 请求Jun 18, 2023 am 09:27 AM

随着互联网的不断发展,HTTP协议已经成为了现代网络通信的基石之一。在Java编程中,通过使用ApacheHttpClient库,可以非常方便地进行HTTP请求操作。本文将介绍如何在JavaAPI开发中使用ApacheHttpClient进行HTTP请求。准备工作在开始之前,需要先下载ApacheHttpClient库,

PHP入门指南:HTTP协议PHP入门指南:HTTP协议May 22, 2023 am 08:06 AM

PHP是一种在互联网应用广泛的编程语言,而HTTP协议是支撑互联网的重要协议。对于初学者而言,学习HTTP协议是入门PHP编程的重要一步。本文将从HTTP协议的基本概念、请求方法、状态码和实际应用等方面介绍HTTP协议的具体内容,以帮助初学者更好地理解和掌握HTTP协议,从而更有效地开发PHP应用程序。HTTP协议的基本概念HTTP协议是HyperText

如何在PHP开发中使用GuzzleHttp进行HTTP请求和处理如何在PHP开发中使用GuzzleHttp进行HTTP请求和处理Jun 25, 2023 am 10:37 AM

在现代Web应用程序中,HTTP请求是必不可少的。为了实现HTTP请求,专业的第三方库是非常必要的。在PHP中,有很多库可以通过HTTP请求与远程服务进行通信,并以JSON、XML等格式访问数据;其中,GuzzleHttp是PHP开发人员中最流行的HTTP客户端之一。在本文中,我们将讨论如何在PHP开发中使用GuzzleHttp进行HTTP请求和处理。一、安

深入探讨HTTP协议状态码的重要性深入探讨HTTP协议状态码的重要性Feb 25, 2024 pm 11:06 PM

深入解读HTTP协议状态码:为什么状态码对于网站开发至关重要随着互联网的迅速发展,网站开发变得越来越重要。在网站开发中,HTTP协议扮演着至关重要的角色。它定义了浏览器和服务器之间的通信规范,通过请求和响应来传输数据。而HTTP状态码就是在这个过程中的一部分,用来表示请求的处理情况。本文将深入解读HTTP协议状态码的作用和意义。HTTP状态码是一个三位数的数

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.