Several lines of ASP code implementation to prevent form repeat submission

Source: Internet
Author: User
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" &AMP;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



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.