Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Users Refreshing page - database problem

Status
Not open for further replies.

WorkSuxs

Programmer
Jan 26, 2005
28
US
I have an asp form that has multiple rows where the users can enter data. When they submit the form, I post to another asp page (if no errors) and will insert the information into a database and display text saying it was processed.

The problem I have is that users are pressing the browsers refresh button and inserting (basically) dupe records into the database. They are not completely dupe since we have unique id numbers generated for each record. I have a work around where I post to one asp page that does the inserting into the database and once it's done, it’s redirected to another page to display the text saying it was processed.

Does anyone have any better ideas?
 
On loading of the processing page you could check for a session variable to be set true or false. If it is false then you process the data and set the session variable to true. If it tests true then you know the page already ran and do not process it again.
If for any reason they have to go back to that form again then you will need to set the session variable to false at the top of that form page so it can process the next request.




Paranoid? ME?? WHO WANTS TO KNOW????
 
i would suggest you to do the following...

Once they submit the form...take them to processing page that does pop up a new alert javascript window saying that their submission was recorded and once they click YES on the alert window..take them back to the original form page or the home page or whatever...

here is how you do the alert window...

<script language="javascript">
window.alert("Your submission is recorded")
window.location="myformpage.asp"
</script>

and the other thing you need to do is...put these 3 lines on the top of your asp page...

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

-DNG


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top