This is a discussion on "Prevent double posting with Post-Redirect-Get" within the PHP Forum section. This forum, and the thread "Prevent double posting with Post-Redirect-Get are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Prevent double posting with Post-Redirect-Get
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Prevent double posting with Post-Redirect-Get
I'm trying to implement measures that prevent double posting when a user clicks the "back" button after a form has been posted. I ran across this article on the "PRG (Post-Redirect-Get) method", but it's written at a very high level, discussing architecture and flow only; there's no how-to or example code.
I get the basic principle, more or less, but I have no idea how to implement it. (That's partly because I never use GET and I'm not completely sure how/when/why to do so.) Has anyone used the PRG method for preventing double-posts? If so, can you please help me to understand it? |
|
|
|
||||
|
Re: Prevent double posting with Post-Redirect-Get
I've always found the PRG method way to overbloated and uneccessary. Set a session variable and when your form is submitted successfully set that variable to sent. Tada, you just prevented yourself from getting the data 2 times AND you didn't have to do a whole lot of coding to prevent it.
Last Blog Entry: Happy Holidays - A Non Offensive way to say Merry Christmas? WRONG! (Dec 11th, 2007)
|
|
|||
|
Re: Prevent double posting with Post-Redirect-Get
But what if the user wants to post again during the same session?! This is a highly interactive site, so that will be common.
|
|
|||
|
Re: Prevent double posting with Post-Redirect-Get
Donny, you can simply "drop" the contents of the cart that have been odered from $_SESSION when the order is placed and stay in the session otherwise. I agree that PRG is (for most uses) rather over the top.
I've been giving a PHP course over the last few days, and the issue of accepting an order into the system ONLY if it came through the right way (no doubling back, no short cuts!) came up. Important stuff for financial institutions. And I've ended up writing a blog item on it which I've just posted. The blog is here and the archived article will appear here if anyone is interested enough to want to get back to it later. |
![]() |
| Tags |
| back button, double posting, prg, refresh |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| double click | ahwell | Flash & Multimedia Forum | 3 | Sep 7th, 2007 20:40 |
| Double Down | colinmcgray | Free Web Site Critique | 8 | Jun 14th, 2007 11:40 |
| Double Backgrounds? | Mourning Dove | Web Page Design | 5 | May 27th, 2006 12:42 |
| prevent refresh in asp | simonneaves | Classic ASP | 2 | Oct 10th, 2005 09:04 |
| Redirect after posting? | Tim356 | Webforumz Suggestions and Feedback | 11 | Dec 13th, 2003 15:42 |