PRG in a nutshell - a clarification

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
urboyfriend
Forum Newbie
Posts: 11
Joined: Tue Sep 06, 2011 6:29 pm

PRG in a nutshell - a clarification

Post by urboyfriend »

basically the concept of prg is to avoid the double submit problem

We could use three php files for that by making a separate files for data input, process and confirmation.

for example:

1). first page is a form with a single text area where user could input data. this page also specifies what page should be called next.

2.) the page called will not be shown to the user, this page retrieves user input from the first page, tries to connect to the database and would eventually try to insert the data specified by the user. After its work is done, it will try to call the third page. probably will call the third page with the header() function?

3.) the third page gives confirmation to the user that the data is successfully entered. this page is only a front end so people can't reprocess when they try to refresh the browser.

am i missing something?

also...

what is the use of this?

header('HTTP/1.1 303 See Other');
Last edited by urboyfriend on Fri Sep 09, 2011 8:40 am, edited 2 times in total.
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Re: PRG in a nutshell - a clarification

Post by ok »

The workflow you wrote above doesn't prevent from pressing twice the submit button, but only prevents from refreshing the page after the form which can cause the form to be resubmitted.

You can use javascript to disable the submit button after the first click.
urboyfriend
Forum Newbie
Posts: 11
Joined: Tue Sep 06, 2011 6:29 pm

Re: PRG in a nutshell - a clarification

Post by urboyfriend »

thank you for the reply :D

so does this means the workflow i stated doesn't satisfy the prg technique?
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Re: PRG in a nutshell - a clarification

Post by ok »

Well, the workflow you stated is PRG (Post/Redirect/Get), however, PRG is not sufficient in order to prevent double form submit...
Post Reply