A detailed description of the difference between post and get in PHP

Source: Internet
Author: User
Tags html header http post

1. The Get method passes the user's data through a URL request, connects the field names in the form with their contents, paired strings, and places the URL of the program that the Action property refers to, such as [url]http://www.jincaib.com/index.php, The data is displayed directly on the URL, just as the user clicks on a link, and the Post method passes the HTTP post mechanism to place the field names within the form with their contents in the HTML header (header) to the server side, which is handled by the program referred to by the Action property. The program will read and process the form's data in standard input (stdin) mode


2, get method need to use Request.QueryString to get the value of the variable, and Post way through Request.Form to access the content of the submission


3, Get way to transfer the amount of data is very small, generally limited to about 2 KB, but the execution efficiency is better than the Post method, and the post way to pass a relatively large amount of data, it is waiting for the server to read data, but also has a byte limit, this is to avoid the server with a large amount of data for malicious attacks, According to Microsoft, Microsoft has a limit on the maximum data that can be received with Request.Form (), with a KB byte in IIS 4 and a KB byte in IIS 5

Recommendation: Unless you are sure that the data you submit can be submitted at once, please use the Post method as much as possible


4, get the way to submit data, will bring security problems, such as a landing page, through the Get method to submit data, the user name and password will appear on the URL, if the page can be cached or other people can access the customer this machine, you can get the user's account and password from the history, So the form submission recommends using the Post method; The common problem with the form page submitted by the Post method is that if the page is refreshed, a dialog box pops up

Recommendation: For security reasons, it is recommended that you use Post to submit data *********************************** in the B/s application, the foreground and background data interaction is done through the form form in HTML. The form provides two ways to transmit data--get and post. Although they are all methods of data submission, they are quite different in actual transmission and can have a serious impact on the data. Although the Web container has shielded some of the differences for the convenience of getting variable values, it is also helpful to understand the differences between the two in future programming.
The Get and post methods in the form, respectively, correspond to the Get and post methods in the HTTP protocol during data transfer. The main differences are as follows:
1, get is used to obtain data from the server, and post is used to pass data to the server.
2. Get adds the data in the form in the form of Variable=value, followed by the URL to which the action points, and both use "?". connections, and each variable is connected by a "&" connection; Post is the data in the form that is placed in the data body of the forms, in the same way that the variables and values are passed to the URL that the action points to.
3, get is not safe, because in the transmission process, the data is placed in the requested URL, and now many existing servers, proxy servers or user agents will log the request URL to the journal file, and then put in a place, so that there may be some privacy information to be seen by third parties. In addition, users can see the submitted data directly in the browser, and some system internal messages will be displayed in front of the user. All the actions of the post are not visible to the user.
4, get transmission of small amount of data, mainly because of the URL length limit, and post can transfer a large amount of data, so the upload file can only use post (of course, there is a reason, will be mentioned later).
5. Get restricts the value of the data set for form forms to be ASCII characters, while Post supports the entire ISO10646 character set.
6, get is the default method for form.
*. When the post transmits data, it does not need to be displayed in the URL, and the Get method is displayed in the URL.
*. The post transmits a large amount of data, which can reach 2 m, and the Get method can only pass about 1024 bytes due to the URL length limit.
*. Post as the name implies, is to transfer data to the server segment, get is to get data from the server segment. And get can also transmit data, just to design tell the server, you need what kind of data. The post information is the content of the HTTP request, and get is transmitted over the HTTP header.

A detailed description of the difference between post and get in PHP

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.