Difference
What is the difference between a post and a get when a form is submitted?
Solution Idea:
The difference between the two needs to be submitted to the form before it can be seen, mainly in the way of data transmission and reception.
Specific steps:
Both post and get are optional values for form property method, and the default value of method is get, and the main difference is:
1. At the client, the Get mode submits the data through the URL, after submitting the address in the Address bar as shown in Figure 1.4.3.
Figure 1.4.3 The Address bar after the form is submitted by Get method
After the post submission, the column is unchanged, as shown in Figure 1.4.4.
Figure 1.4.4 the address bar after submitting a form post
2. On the server side can only use Request.QueryString to obtain the data submitted by the Get method, the data submitted by post method can only be obtained by Request.Form:
<% @language = "VBScript" codepage= "936"%>
<title> form submission Test </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body>
<form method= "POST" action= "<%=request.servervariables (" Script_name ")%>" >
Submit data:
<input name= "Ostr" type= "text" >
<br>
Submission Method:
<select name= "Select" >
<option value= "Post" selected>post</option>
<option value= "Get" >Get</option>
</select>
<br>
<input type= "Submit" name= "Submission" value= "submitted" >
</form>
<%
If Request ("Submit") <> "then"
The data submitted by the Response.Write "Through" &request.servervariables ("Request_method") & "is:"
If Request.ServerVariables ("request_method") = "Get" Then
Response.Write Request.QueryString ("Ostr")
Else
Response.Write Request.Form ("Ostr")
End If
End If
%>
</body>
Note: Although both submissions can be unified using request ("OSTR") to obtain submission data, this has an impact on program efficiency and is not recommended.
Special Tips
Run this example code through IIS (Http://localhost/method.asp this way, for the installation and configuration of IIS, refer to part Fourth), enter the submitted data, select Post method submission, you will see the effect shown in Figure 1.4.4. Select the Get method submission, and the effect will be as shown in Figure 1.4.3.
Special note
In general, try to avoid submitting forms using get, because it can lead to security issues. For example, in the landing form in the get way, the user entered the user name and password will be exposed in the address bar. In a paging program, however, it is better to use get than to post. The properties of the form used in this example are interpreted (see part fourth for the ASP section):
Get to add the parameter to the address specified by the Action property and open it in an anchor mode.
Post processes send data through HTTP POST processing.