You are here: Re: Refresh problem and posts « All PHP « IT news, forums, messages
Re: Refresh problem and posts

Posted by ZeldorBlat on 09/19/05 00:14

Gordon is right...you need to keep some sort of state -- either in a
session variable or cookie.

What I usually do (and believe me, it isn't perfect) is to set some
random identifier at the top of the page. Call it $curPageId.
Whenever I draw a post form, I include the value of curPageId as a
hidden post parameter. At the top of the next page, set another
session variable called $prevPageId to the value of $curPageId, and set
a new random value for $curPageId. Then, before processing the form,
check that the value of $prevPageId from the session is the same as the
value of the form variable that was submitted. If it is, you can
process the form. If they are different, you know that the form was
refreshed.

Of course, if you want to store the value in a cookie instead of a
session, that's fine, too -- although I tend to prefer the session.

As I said before, the approach isn't perfect. You can, of course, run
into problems with multiple windows or tabs viewing the same pages.

 

Navigation:

[Reply to this 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

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