Separation between View and State (The Back Button)

M

Michael B Allen

Let's say you have a "Buy" botton that posts a form to a script that
inserts or increments the quantity of a record in a shopping cart
table. So you click "Buy" and then "Checkout". Now if you hit the Back
button it asks the user if they would like to repost the form. If they
click "Ok" the db script runs again and now they have two items in
the cart.

It seems to me this is a fundamental model view controller kind of
problem. There's no seperation between the view and the controller. Can
someone recommend a generic method for providing that seperation? I could
have the script emit a Location header but that's a strange hack. What
is the definitive method for solving this probably very common issue?

Thanks,
Mike
 
V

Vincent van Beveren

It seems to me this is a fundamental model view controller kind of
problem. There's no seperation between the view and the controller. Can
someone recommend a generic method for providing that seperation? I could
have the script emit a Location header but that's a strange hack. What
is the definitive method for solving this probably very common issue?

I don't see how JavaScript would solve this problem. Generally you'd do
a redirect after a submit. Because the redirect is not a POST the
browser forgets the post. Doing a back will cause you to go back to the
page which was requested with a GET, thus no repost. I think you can
better ask this question on a server-side-something form, like Servlets,
PHP or ASP.

Cheers,
Vincent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top