In many cases, it is necessary to prevent the same form from being submitted multiple times. Many people's implementation methods are complicated (the number of code lines exceeds dozens !!) The following provides a method that uses only a few lines of code to easily prevent users from refresh the submitted form multiple times and use the back button to submit the form multiple times.
China site. Long SITE
File 1: Form file formtest. asp
Reference content is as follows:
<%
Randomize 'initial random number Seed
Num1 = RND () 'generates a random number num1
Num1 = int (26 * num1) + 65' modify the num1 range to make it an ascii code for the A-Z range to prevent form name errors
Session ("antry") = "test" & CHR (num1) 'generates a random string
%>
<Form name = "test" Action = "testact. asp" method = "Post">
Your name: <input type = 'text' name = ''size = 30> 'note that the random form item name is used in this row.
<Input type = 'submit 'value = 'Submit'>
</Form>
Form handler testact. asp
<%
Teststr = request. Form (Session ("antry "))
If teststr = "" then
Response. Write "no name or repeated submission"
'The user did not enter the name, or the form was submitted repeatedly (marked as Session ("antry") is empty ).
Else
Response. Write teststr
Session ("antry") = "" 'submitted successfully. Clear SESSION ("antry") to prevent repeated submission !!
End if
%>