In many cases, it is necessary to prevent the same form from being submitted multiple times, and many people's implementations are more complex (code counts more than dozens of lines!!) The following provides a way to use just a few lines of code, easily to prevent users from refreshing multiple submission forms and to repeat them multiple times with the back button.
File One: Form file formtest.asp
<%
Randomize '初始代随机数种子
num1=rnd() '产生随机数num1
num1=int(26*num1)+65 '修改num1的范围以使其是A-Z范围的Ascii码,以防表单名出错
session("antry")="test"&chr(num1) '产生随机字符串
%>
<form name="test" action="testact.asp" method="post">
你的名字:<input type='text' name='' size=30> '注意本行中使用了随机表单项名
<input type='submit' value='提交'>
</form>
Form Handler testact.asp
<%
teststr=request.form(session("antry"))
if teststr="" then
response.write "没有填写姓名或重复提交"
'由于用户没有填写名字,或表单被重复提交(标志为session("antry")为空)引起
else
response.write teststr
session("antry")="" '提交成功,清空session("antry"),以防重复提交!!
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