Repeat | Commit with several lines of ASP code to prevent a form from being submitted multiple times
Liao
In many cases it is necessary to prevent the same form from being submitted multiple times, and many people are implementing it in a more complex way (more than a few
10 lines!! The following provides a way to use just a few lines of code, easily to prevent users from refreshing multiple submission forms and after using
The fallback button repeats the form multiple times.
Form file formtest.asp
<%
Randomize ' initial generation random number seed
Num1=rnd () ' produces random numbers NUM1
Num1=int (26*NUM1) +65 ' modifies NUM1 range so that it is a-Z-wide ASCII code to prevent table Single-name errors
Session ("antry") = "test" &CHR (NUM1) ' produces a random string
%>
<form name= "test" action= "testact.asp" method= "POST" >
Your name: <input type= ' text ' name= ' size=30> ' note the Random form item name is used in the bank
<input type= ' Submit ' value= ' submitted ' >
</form>
Form Handler testact.asp
<%
Teststr=request.form (Session ("Antry"))
If teststr= "" Then
Response.Write "did not fill in the name or repeat the submission"
' Cause the user did not fill in the name, or the form is repeated (the flag is null for session ("Antry"))
Else
Response.Write Teststr
Session ("antry") = "' Submit successfully, empty session (" Antry "), in case of repeated submission!!
End If
%>
In this case, you only need to randomize the form item name of a required item so that you do not have to randomize all the form items.
Welcome to my personal homepage http://swuse.yeah.net