Get and post methods in form,
During data transmission, the get and post parties in the HTTP protocol areMethod. The main differences between the two are as follows:
2. Get returns the data in the form according to variable =Value form, added to the end of the URL pointed to by the action,And the two use "?" And various variables are connected by "&". Post puts the data in the form data body,The URL to which the action is directed is passed according to the method in which the variables and values correspond.
3. Get is insecure, because in the transmission process,Data is stored in the request URL, while many existing servers,The proxy server or user agent will record the request URL to the log file and place it somewhere, so that some private information may be seen by a third party.In addition, you can view the submitted data directly in the browser,Some internal messages are displayed in front of users. All post operations are invisible to users.
4. The size of data transmitted by get is small, mainly because the URL length is limited;While post can transmit a large amount of data,Therefore, only post can be used to upload files (of course, there is another reason,As mentioned later ).
5. Get restricts that the dataset value of the form form must be ASCII characters;The post function supports the entire iso000046 character set.
6. Get is the default form method.
The path method is entered in the quotation marks of action,Such as sending emails or other web pages.
POST requests can only be applicable to transfer requests between pages,Enter the address directly from the address bar. The POST request cannot be sent,In the case of post, the <input> Field of the previous page is passed to the server as a parameter. In the case of get,The parameter depends on "?" In the address The following string is a parameter.The address specified by the src attribute in the frame is exactly the same as the address entered in the address bar,The request is a GET request.
Both get and post Methods send data to the server,But which one should you use?
The HTTP standard includes these two methods for different purposes.Post is used to create resources,The resource content will be included in the HTTP request content. For example, processing the order form,InDatabaseAdd new data rows.
When the request has no side effects (such as search), you can use the get method;When the request has side effects (such as adding data rows to the database), the POST method is used.A more practical problem is that the get method may produce a long URL,It may exceed the URL length limit of Some browsers and servers.
If any of the following conditions is met, the POST method is used:
- The request results have continuous side effects, such as adding new data rows to the database.
- If the get method is used, the data collected on the form may make the URL too long.
- The data to be transmitted is not encoded in 7-bit ASCII format.
If any of the following conditions is met, use the get method:
- The request is for searching resources. HTML form data is only used for searching.
- The request results have no sustained side effects.
- The total length of the collected data and input field names in the HTML form cannot exceed 1024Characters.
There are 5 Differences Between get and post methods in Form submission.
1. Get is to get data from the server, and post is to send data to the server.
2. Get is to add the parameter data queue to the U specified by the Action attribute of the submission form.In RL, the values correspond to each field in the form one by one, which can be seen in the URL.Post uses the http post mechanism to place fields in the form and their content in the HTML header and send them to the URL address referred to by the Action attribute.You cannot see this process.
3. For the get method, the server uses request.QuerystringObtains the value of a variable. For post,The server uses request. Form to obtain the submitted data.
4. The data volume transmitted by get is small and cannot exceed 2 kb.The amount of data transmitted by post is large, which is generally not restricted by default. However, theoretically,The maximum size of IIS4 is 80 KB, and that of iis5 is kb.
5. Low get security and high post security.