Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2003
    Posts
    15

    Unanswered: 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

  2. #2
    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

  3. #3
    Join Date
    Feb 2003
    Posts
    15
    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....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •