| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am working with website in which a user can login and then submit some forms. I want the user to avoid re-submitting the same form twice when he uses the browser refresh or when he goes to another page and then comes back to that same page using the browser back button.
I know of two solutions: 1. Redirect to a different page after form submission - The problem with this approach is that the website has many forms. So redirecting each form to a different one is not a very feasible solution. 2. A token can be stored in session (or somewhere) after each form submission. These tokens can be verified if the form is being resubmitted - The problem with this approach is that the user can submit one form only once. I want the user to be able to submit the same form multiple times, provided with different data. Is there a suitable solution where a form with same data is submitted only once, but there is no such restriction with different data? (Storing ALL the information filled in each form during that session and then comparing for resubmit is not a clean solution I think??). Thanks. |
|
#2
|
||||
|
||||
|
Maybe you could store the info in a cookie. Then, when the user posts the form, read the cookie contents to see if he/she has already posted the same information once. If so, don't process the form. Display a message.
Does this help? |
|
#3
|
|||
|
|||
|
Use a redirect on the sumission page.
__________________
|
|
#4
|
|||
|
|||
|
On each form create a hidden field that holds a randomly generated string.
When the user submits the form store this id in an array and save it as a session variable. If the the incoming posted form id against this array to see if that instance of the form has been posted before. As the form id is random it won't stop users filling in the form again and posting it, just stop them from resubmitting the same form. |
|
#5
|
||||
|
||||
|
Quote:
This is what I do for my company's forms and it works well. Gives the added control over the content being submitted.
__________________
If you found a post of mine helpful, please click on the on my post to add to my reputation.
|
|
#6
|
|||
|
|||
|
Use a hidden field call it "redirectMeToWhereICameFrom" and then get the current URL
<%=(request.servervariables("URL"))%> then whereever you are posting your form, when you've done whats needed to be done i.e. added shopping cart content or dropped the details into a DB use a simple <% response.redirct(request.form("redirectMeToWhereICameFrom"))%> Simple |
![]() |
| Viewing: ASP Free Forums > Web Design > Web Layout > Avoid form resubmission when REFRESH clicked |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|