Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2004
    Posts
    84

    Unanswered: Refresh causes double submit (post)

    ASP problem:

    If user refreshes the browser window, or if user clicks twice onto the submit button, SQL query is executed twice, the table gets two new rows.

    I found many possible solutions, but not the complete one - every solution has it's problems.

    Any good idea about how to solve the problem?

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    No clue, need to no more about what you're doing now.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Mar 2004
    Posts
    84
    It's the issue that happened very often at Guestbooks and Forums.

    If user clicks Submit (Post) button twice (double click), or refreshes the window (waiting for the response), there will be double entry in the database (two records, same content).

    How to avoid the problem? Any idea?

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    That's what the USER is doing. What are YOU doing when they click a button? Submission forms aren't powered by pixie dust and coffee. They need to be implemented somehow...
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Mar 2004
    Posts
    84
    What does seem to be the problem?

    The ASP code was already made. I am just trying to recreate it to work without any problem. Anybody has idea about the solution? Anybody experienced double submit by clicking the button twice or by refreshing the window?

  6. #6
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    I think the problem is you don't know how that code works, and we can't help you if you can't describe what the code does.

    ProTip: "It submits things" is not a valid answer.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  7. #7
    Join Date
    Nov 2005
    Location
    San Francisco, CA
    Posts
    506
    Quote Originally Posted by Teddy
    I think the problem is you don't know how that code works, and we can't help you if you can't describe what the code does.

    ProTip: "It submits things" is not a valid answer.
    Hi Teddy,
    I have experienced this same problem once.

    The first page contain -
    A textfield and a button in form tag.
    Region.asp
    <form name="form1" method="post" action="regionupdate.asp">
    <input type="text" name="textfield" value="">
    <input type="submit" name="Submit" value="Submit" onclick="<% SESSION("update_ok")=true%>">
    </form>
    And Regionupdate.asp
    I am not writing the whole code here just few lines...

    conn.BeginTrans
    conn.Execute "INSERT INTO REGION(r_code,r_name) VALUES ('" & strcode & "','" & trim(Request.Form("textfield")) & "')"

    conn.CommitTrans
    If a user after coming back to the first, presses the refresh button the previous data is sent to the server.
    I dealt with this problem by using clientside validation javascript.
    window.document.location.replace("url")
    writing it at the head tag of the first page.
    I hope to hear more solutions to this problem.
    Success is the ability to go from one failure to another with no loss of enthusiasm.
    - Sir Winston Churchill
    Joydeep

  8. #8
    Join Date
    Aug 2004
    Posts
    96
    Anoterh way to do it would be to use 3 pages.
    page1.asp has the form which sends the data to page2.asp, a purely asp page which insert the record and sent redirect to page3.asp to thank the user, if page 3 if refreshed it doesnt' actully do any thing, if the browser back is used you need to block that by adding a script to page 1:
    <body onload="javascript:window.history.forward(1);">

    As for the button clicked twice you can disable it or hise once clicked using javascript

    Hope this helps
    Olivier

  9. #9
    Join Date
    Apr 2006
    Posts
    1
    Set the smart navigation property to true

Posting Permissions

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