Differences between Get and Post methods in html form submission

Source: Internet
Author: User
Tags html form html header http post

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 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 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. If no Method is specified, the default value is GET. The data submitted in Form will be appended to the url? Separated from the url.

3. For the get method, use Request. QueryString in asp to GET the variable value, and use $ _ get in php. For post mode, asp uses Request. Form to obtain submitted data, and php uses $ _ POST 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.

5. Low get security and high post security.

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

The code is as follows: Copy code
<〈! -Two forms have different Method attributes.-> -〉
<Form action = "getpost. asp" METHOD = "get "?
<Input type = "text" NAME = "Text" VALUE = "Hello World"> </INPUT> 〉
<Input type = "submit" VALUE = "Method = get"> </INPUT> 〉
</FORM> 〉
<BR> 〉
<Form action = "getpost. asp" 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. asp? 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. asp? 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

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.