ASP implementation method to prevent duplicate submission data

Source: Internet
Author: User
The code is as follows Copy Code

Session (' Time ') =now ()
Const a= #0:0:4# ' defines the number of seconds between intervals
If session ("Time2") >0 then ' if a value
If session ("Time2") +a > Sessions ("Time") Then '
Session ("Time2") =now ()
Response.Redirect "Look.asp"
End If
End If
Session ("Time2") =now ()

Method Two

Make a counter on this page

The code is as follows Copy Code

<%
If request ("form content") = "" Then
Session ("num") =0
Else
Session ("Num") =session ("num") +1
End If

' After submission
If session ("num") >0 Then
Response.Write "Do not submit data again!"
Response.End
End If
%>

Method Three

Use cookies or sessions to process. Here is an example of a cookie:
Add.asp

  code is as follows copy code

<% Response.Cookies ("submitflag") = "no"%>

save.asp

<%
If Request.Cookies ("submitflag") = "yes" Then
    Response.Write "You cannot submit data repeatedly!"
    response.end
End If

Rs. AddNew
...
Rs.update
Rs.close

Response.Cookies ("submitflag") = "yes"
%>

Database operation

Set rs= Conn.execute ("Select top 1 txt from DB where txt= '" &reqtxt& ")
If not (rs.eof Or rs.bof) then
  Respon Se.write "Do not allow duplicate commits"
Else
  Add data ....
End If

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.