Re: handling a user pressing browser's back button

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* James <jtu@xxxxxxxxxxxxx>:
> Currently I have an application with PHP scripts that passes POST 
> variables to keep track of ID's of records, the processing mode and 
> such.
>
> I totally didn't design it to handle when a user hits the Back button 
> in the browser...everything is tightly controlled...The user clicks 
> on links/buttons to take actions.
>
> So far the database updates are fine and almost everything behaves 
> correctly when the user hits the back button.  However, I do have one 
> page that shows a list of records.  The user clicks "Edit" and the 
> list is shown again, but this time with the selected record as 
> Editable fields.  If the user presses the Browser's Back button, the 
> record still appears as Editable.  This is just one of those cases.
>
> What have people done in the past to deal with states and such and 
> keeping these things straight when the user hits the BACK button?

This has come up on the list several times in the past month, and if you
search the archives, you should be able to find a detailed answer. The
short answer, to which you will need to fill in the gaps is:

1. Display form on page 1. Page 1 has Cache-Control: no-cache header.
2. User submits form to page 2
3. Page 2 processes form, stores required variables in session, and then
   redirects to page 3.
4. Page 3 displays results (success page, search results, etc.)

At this point, when you hit the back button, you *should* get to page
1... which, because of the no-cache header, is forced to reload.

Alternatively, you set a session variable indicating that the action has
already occurred so that when user submits form again, you check for
existence of said session variable, and, if found, display an error.

-- 
Matthew Weier O'Phinney           | WEBSITES:
Webmaster and IT Specialist       | http://www.garden.org
National Gardening Association    | http://www.kidsgardening.com
802-863-5251 x156                 | http://nationalgardenmonth.org
mailto:matthew@xxxxxxxxxx         | http://vermontbotanical.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux