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