What is the difference between form submission methods post and get?
Solution :
The difference between the two can be seen only after the form is submitted, mainly in the data transmission mode and receiving mode.
Procedure :
Both post and get are optional values of the form attribute method. The default value of method is get. The main differences between the two are:
1. on the client side, the get method submits data through the URL, as shown in address 1.4.3 in the address bar after submission.
Figure 1.4.3 address bar after the form is submitted in get Mode
The Location Bar remains unchanged after post is submitted, as shown in 1.4.4.
Figure 1.4.4 the address bar remains unchanged after the form is submitted in post mode.
2. on the server side, only request. querystring can be used to obtain data submitted in get mode. data submitted in post mode can only be obtained using request. Form:
<% @ Language = "VBScript" codePage = "936" %>
<HTML>
<Head>
<Title> test the form submission method </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
</Head>
<Body>
<Form method = "Post" Action = "<% = request. servervariables (" script_name ") %>">
Submit data:
<Input name = "ostr" type = "text">
<Br>
Submission method:
<Select name = "select" onchange = "This. Form. method = This. Value">
<Option value = "Post" selected> post </option>
<Option value = "get"> Get </option>
</SELECT>
<Br>
<Input type = "Submit" name = "Submit" value = "Submit">
</Form>
<%
If request ("Submit") <> "then
Response. Write "data submitted 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>
</Html>
Note: although the two submission methods can use request ("ostr") to obtain the submitted dataProgramEfficiency is affected and is not recommended.
Note
Run this example through IISCode(Use http: // localhost/method. for more information about IIS installation and configuration, see Section 4. Enter the submitted data and select post to submit. The result shown in Figure 1.4.4 is displayed. Select get to submit, as shown in Figure 1.4.3. Note
In general, try to avoid using the get method to submit a form because it may cause security problems. For example, if you use the get method in the login form, the user name and password entered by the user will be exposed in the address bar. However, in the paging program, the get method is better than the POST method. Attribute explanation of the form used in this example (see Section 4 for ASP ):
Get adds the parameter to the address specified by the Action attribute and opens it as an anchor.
Post processes sent data through http post.