Implementing a few lines of ASP code to prevent forms from being submitted

zhaozj2021-02-17  47

Implementing a few lines of ASP code to prevent forms from being submitted

Author: Liao far

In many cases, it is necessary to prevent the same form from being submitted many times. Many people's implementation methods are more complicated (the number of codes exceeds dozens of lines !!) The following provides a method of simply use a few lines of code, easy to implement Prevent users from refreshing multiple submission forms and uses the return button repeatedly to submit a form.

Form file FormTest.asp

<% Randomize 'initial random seed

Num1 = rND () 'Generate random number Num1

Num1 = int (26 * num1) 65 'Modify the range of NUM1 to make it a ASCII code in the A-Z range to prevent the form of a single name

Session ("antry") = "test" & chr (num1) "Generate random strings

%>

Your name: 'Note the random form name in this Bank

Form processing program Testact.asp

<%

Teststr = Request.form (SESSION ("Antry"))

IF teststr = "" "

Response.write "No name or repeated submission"

'Since the user does not fill in the name, or the form is repeated (the mark is empty) is empty ("antry")

Else

Response.Write Teststr

Session ("Antry") = "" "Submit success, empty session (" antry ") to prevent repetition! !

END IF

%>

Here, you only need to randomize a form item name that must be item, you don't have to random all form items.

Welcome to my Personal Home http://swuse.yeah.net

转载请注明原文地址:https://www.9cbs.com/read-29842.html

New Post(0)