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 > Refresh causes double submit (post)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-05-06, 09:32
computerforce computerforce is offline
Registered User
 
Join Date: Mar 2004
Posts: 84
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?
Reply With Quote
  #2 (permalink)  
Old 04-05-06, 10:08
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
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? ***
Reply With Quote
  #3 (permalink)  
Old 04-06-06, 02:20
computerforce computerforce is offline
Registered User
 
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?
Reply With Quote
  #4 (permalink)  
Old 04-06-06, 13:34
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
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? ***
Reply With Quote
  #5 (permalink)  
Old 04-10-06, 05:54
computerforce computerforce is offline
Registered User
 
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?
Reply With Quote
  #6 (permalink)  
Old 04-10-06, 10:29
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
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? ***
Reply With Quote
  #7 (permalink)  
Old 04-10-06, 15:20
rudra rudra is offline
L O S T in Reality
 
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
Quote:
<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
Quote:
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.
Quote:
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
Reply With Quote
  #8 (permalink)  
Old 04-12-06, 10:44
oliflorence oliflorence is offline
Registered User
 
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
Reply With Quote
  #9 (permalink)  
Old 04-25-06, 15:52
Smart Smart is offline
Registered User
 
Join Date: Apr 2006
Posts: 1
Set the smart navigation property to true
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