Difference between get and post methods in Form submission

Source: Internet
Author: User
Tags html header

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 adds the parameter data queue to the URL referred to by the Action attribute of the submission form. The values correspond to each field in the form one by one and can be seen in the URL. Post is implemented through HTTP
Post mechanism: place the 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. querystring to obtain the value of the variable. For the POST method, 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. Theoretically, the maximum size of IIS4 is 80 KB, and that of iis5 is 100kb.

5. Low get security and high post security.

HTTP Request: difference between get and post Methods

HTTP defines different methods for interaction with the server. The most basic methods are get and post. In fact, get applies to most requests, while retaining post
Only used to update sites. According to the HTTP specification, get is used for information retrieval and should be
Secure and idempotent. The so-called security means that this operation is used to obtain information instead of modifying information. In other words, get requests generally do not have side effects. Idempotence means the same URL
The same results should be returned for multiple requests. The complete definition is not as strict as it looks. Basically, the goal is that when a user opens a link, she can be confident that the resource has not changed from her own perspective.

For example, the front pages of news sites are constantly updated. Although the second request will return a different batch of news, this operation is still considered safe and idempotent because it always returns the current news. And vice versa. Post
The request is not that easy. Post indicates a request that may change resources on the server. Taking the news site as an example, the reader's comment on the article should be post
Request implementation, because the site is already different after the annotation is submitted (for example, an annotation appears below the article );

If method is not specified during form submission, the default value is get. The data submitted in form will be appended to the URL? Separated from the URL. Letter/Digit
The original character sample is sent, but the space is converted to "+". Other symbols are converted to % xx. xx indicates the ASCII (or ISO
Latin-1) value. For a GET request, the data to be submitted is placed in the HTTP Request Header, while for a POST request, the data to be submitted is placed in the object data. For a GET request, only
1024 bytes, whereas post does not.

What is the difference between using "Post" and "get" in a form?

In form, you can use post or get. They are all valid values of method. However, the post and get methods are at least two different in use:

1. The get method transmits user input through URL requests. The post method is in another form.

2. You need to use request. querystring to obtain the value of the variable for get-based submission. When using post-based submission, you must use request. Form to access the submitted content.

Study the following code carefully. You can run it to feel it:

Code

Reference content is as follows:

<! -- Two forms have different method Attributes -->

<Form action = "getpost. php" method = "get">

<Input type = "text" name = "text" value = "Hello World"> </input>

<Input type = "Submit" value = "method = get"> </input>

</Form>
<Br>

<Form action = "getpost. php" method = "Post">

<Input type = "text" name = "text" value = "Hello World"> </input>

<Input type = "Submit" value = "method = post"> </input>

</Form>

<Br>

<Br>

<? If request. querystring ("text") <> "" then?>

The string passed through the get method is: "<B> <? = Request. querystring ("text")?> </B> "<br>

<? End if?>

<? If request. form ("text") <> "then?>

The string passed through the POST method is: "<B> <? = Request. Form ("text")?> </B> "<br>

<? End if?>

Description

Save the above Code as getpost. asp and run it. First test the POST method. At this time, the URL of the browser does not change, and the returned result is:

The string passed through the POST method is: "Hello World"

Then test the submission using the get method. Note that the URL of the browser is changed:

Http: // localhost/General/form/getpost. php? TEXT = Hello + world

The returned result is:

The string passed through the get method is: "Hello World"

Finally, submit the file through the POST method. The URL of the browser is:

Http: // localhost/General/form/getpost. php? TEXT = Hello + world

The returned result is:

The string passed through the get method is: "Hello World"

The string passed through the POST method is: "Hello World"

Prompt

Submitting data through the get method may cause security issues. For example, a login page. When you submit data using the get method, the user name and password will appear on the URL. If:

1. the login page can be cached by the browser;

2. Others can access the customer's machine.

Then, others can read the customer's account and password from the browser's history. Therefore, in some cases, the get method may cause serious security problems.
Suggestions
In form, the POST method is recommended.

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.