Prevent double posting with Post-Redirect-Get

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.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Apr 27th, 2007, 20:31
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
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?
Reply With Quote

  #2 (permalink)  
Old Apr 27th, 2007, 21:50
JustinStudios's Avatar
SuperMember

SuperMember
Join Date: Mar 2007
Location: USA
Posts: 406
Blog Entries: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to JustinStudios
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.
Reply With Quote
  #3 (permalink)  
Old Apr 27th, 2007, 22:36
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
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.
Reply With Quote
  #4 (permalink)  
Old Apr 28th, 2007, 07:04
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Reply With Quote
Reply

Tags
back button, double posting, prg, refresh

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 18:34.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43