Reply to Re: handling a user pressing browser's back button

Your name:

Reply:


Posted by Matthew Weier O'Phinney on 09/25/49 11:14

* James <jtu@esidesign.com>:
> 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@garden.org | http://vermontbotanical.org

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация