If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Stopping multiple submissions of a form

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-07-03, 09:27
nmd nmd is offline
Registered User
 
Join Date: Feb 2003
Posts: 15
Stopping multiple submissions of a form

I'm looking for an effective way of prventing a user from submitting a form twice.

The form passes its conents to a script which adds the new details to the database and the user is then redirected to a response page.

I've used some java script to prevent a user pressing submit repeatedly if there is any delay in the redirect.

My problem is how to prevent a user pressing back on their browser and just submitting again.

I've considered using a session value to stop this. So when the db script is run a session value is set. Which the script checks for before it processes along the lines of:

if isempty(session("submit")) Then
- process db
- set session("submit") = "true"
Else
- redirect to an error "multiple submissions"
End If

If anyone can expand on this or provide a better solution it would be very usefull.

Thanks, nmd
Reply With Quote
  #2 (permalink)  
Old 02-07-03, 10:53
Memnoch1207 Memnoch1207 is offline
Registered User
 
Join Date: Jan 2003
Location: Midwest
Posts: 138
Prior to the user submitting the for the first time set the Session("submit") value to true..after the form has been submitted set the Session("submit") value to false...

on the submit page check the session("submit") value then do your processing.

If(Session("submit") = true) then
submit the form
Session("submit") = False
else
response.redirect("/multiplesubmissions.asp")
end if
Reply With Quote
  #3 (permalink)  
Old 02-07-03, 11:05
nmd nmd is offline
Registered User
 
Join Date: Feb 2003
Posts: 15
Quote:
Originally posted by Memnoch1207
Prior to the user submitting the for the first time set the Session("submit") value to true..after the form has been submitted set the Session("submit") value to false...

on the submit page check the session("submit") value then do your processing.

If(Session("submit") = true) then
submit the form
Session("submit") = False
else
response.redirect("/multiplesubmissions.asp")
end if
Thanks so I was along the right lines, can you think of any other ways of preventing multiple submits, I've also used the following:

'content expire
<% Response.CacheControl = "no-cache" %>
<% Response.AddHeader "Pragma", "no-cache" %>
<% Response.Expires = -1 %>

'check content was posted - to prevent linking to page from history
<%
if Request.ServerVariables("request_method")<>"POST" then
response.Redirect "/error.asp"
end if
%>

Should this be enough or am I just being over cautious, the table I am submitting to could have two companies with exactly the same details being added / well the company name at least, so I can't realy scan the table to check for duplicates.

Unless I set a timestamp on the form and add that to the table and scan for duplicate timestamps when data is submitted to it. What do you think.

Thanks again....
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On