473,320 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

MVC form submission POST-Redirect-GET problem

dlite922
1,584 Expert 1GB
Guys, my brains fried and is not working. need your help.

I've got an Entity let's call it "Item",

in my Item controller I have the following actions

/item/index
:: Views the item, submits POST to /save

/item/update
:: Validates and saves Item fields to DB and redirects back to /index

/item/create
:: Creates a blank form to add a new Item, submits to itself, validates, saves and redirects to /index to view it.

/item/delete
:: Confirms delete, deletes from database if yes, and redirect back to /list/


My question is how do you guys prevent resubmission of the data to the DB, if the user clicks the back button?

303 Redirect? like this: http://en.wikipedia.org/wiki/Post/Redirect/Get

Is there anyway for header("Location..") to wipe the history and replace the page just like javascript window.location.replace() ?

Thanks,

Dan
Dec 17 '11 #1
5 2736
zorgi
431 Expert 256MB
Could you:
  1. store uniqid() into the session and same id into the hidden field on your form
  2. when submitting check if hidden field and session hold the same value
  3. if values correspond submit was valid -> destroy session to prevent further submits using same uniqid
  4. if values do not correspond than its a case of double submit
Dec 18 '11 #2
dlite922
1,584 Expert 1GB
I'm going to try to stay away from session if possible and look for a minimal maintenance/ elegant solution. Perhaps session is the only way, however I haven't quit yet...

Dan
Dec 19 '11 #3
zorgi
431 Expert 256MB
I had similar issue recently and wanted to stay away from session just like you are trying now. I gave up on the end and did session thing. My problem was slightly different. I wanted to prevent quick double click submit. Are you using ZF or some other framework.
Dec 19 '11 #4
dlite922
1,584 Expert 1GB
I'm using a self-made bare-bones framework. (mod-rewrite and call_user_func() basically)
Dec 20 '11 #5
zorgi
431 Expert 256MB
Oh well... Reson I asked is that I have Zend_Form ready made solution to this problem.
Dec 20 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Pamela Chatterjee | last post by:
In my Web Form I have more than one Textbox for user input. If I hit enter to any Textbox its submitting the form. How can I prevent Form submission if users hit enter to the textbox? I want to...
2
by: Kimmo R. M. Hovi | last post by:
Currently I have defined: -- clip clip -- <form method="post" action="xx" enctype="application/x-www-form-urlencoded"> <input type="image" name="Function 1" src="image1.gif" border="0"...
2
by: adawson | last post by:
Hi, I need to execute some code when form submission is stopped before the page is returned from the server. For example, a user clicks a button to submit the form, realizes they've made a...
4
by: Flex | last post by:
Hi everybody, what's the code for a form submission in a new window? i wasn't sure it it should go in the form action tag, or in the submit button. I tried something like this: <form ...
4
by: kschneider | last post by:
Assume there's a form with it's action attribute all set to post to a URL, but without a submit control. Form submission is done via a link and I want to prevent the classic "double submit"....
6
by: Oleg Konovalov | last post by:
Hi, I have a Java/JavaScript GUI application where I perform a lot of long DB operations , which takes 5-60 secs to perform. Sometimes user double-clicks the button or just gets impatient and...
2
by: Peter Michaux | last post by:
Hi, Is there any way to watch regular form submission leave the browser? I have a complicated dynamic form to learn about and instead of sorting through the code I would like to see what is...
1
by: skyy | last post by:
Hi, Is there any way to check the status of a form submission using javascript? Check whether the form submission is finished? thanks!
1
by: rn5arn5a | last post by:
Nowadays, most websites make use of CAPTCHA to prevent automated Form submission. Can someone please give me examples of how automated Form submission can be achieved? It's not that I intend to...
6
by: Stanimir Stamenkov | last post by:
I have a form without a submit button like: <form name="form1" action="" onsubmit="alert('submit ' + this.name);"> <div> <label>Field 1: <input type="text" name="field1"...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.