|
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]
|