For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > August 2005 > Expiring $_POST variables









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Expiring $_POST variables
Martin A. Weinberger

2005-08-30, 9:55 pm

Hi all,

I'm using a hidden button as shown in the following line to determine upon
entry (or re-entry) to the PHP file, whether or not to process the form
data.

<input type="hidden" name="validateme" value="doit">

The form contains anchor tags to link to other pages. From this point of
view the form works perfectly. The problem is that, when the user goes back
to this page later on, the "validateme" posted variable does not expire, so
the form tries to reprocess the form, even though there is no form to show.
My question is how can I reset the validateme to nothing (""), so that the
user doesn't wind up reprocessing the page upon reentry at a later time.

I'm accessing the validateme using the "$CmdDoIt = $_POST["validateme"];"
line.

Thanks in advance,

--
Martin A. Weinberger
ButterflyVista
http://www.butterflyvista.com/


Michael Trausch

2005-08-31, 3:56 am

Martin A. Weinberger wrote:
>
> I'm using a hidden button as shown in the following line to determine upon
> entry (or re-entry) to the PHP file, whether or not to process the form
> data.
>
> <input type="hidden" name="validateme" value="doit">
>
> The form contains anchor tags to link to other pages. From this point of
> view the form works perfectly. The problem is that, when the user goes back
> to this page later on, the "validateme" posted variable does not expire, so
> the form tries to reprocess the form, even though there is no form to show.
> My question is how can I reset the validateme to nothing (""), so that the
> user doesn't wind up reprocessing the page upon reentry at a later time.
>
> I'm accessing the validateme using the "$CmdDoIt = $_POST["validateme"];"
> line.
>
> Thanks in advance,
>


In theory, you could use JavaScript to protect it by detecting when the
"back" button is hit, and set the variable to a known bad value that you
can check against in the PHP script.

However, in practice, I wouldn't know how to do that, exactly. From
what I *do* understand of JavaScript, it's possible to "hook" buttons
like that, and I've seen it implemented in places before, though it's
been a little while since I've done that.

However, you still have to worry about some other scenerios, then. What
if the user has disabled JavaScript, or is still using a browser that
doesn't support it well or at all? (Hey, it's possible.)

I'm not sure about how you'd handle those particular questions.

- Mike
Martin A. Weinberger

2005-08-31, 3:56 am

Hi Michael and all,

I'm embarassed to even write what the problem was. I forgot to update the
form to reflect processing the new form. It processed the form that I tried
to go to, which caused the error. It took me quite a while to figure out a
simple bug. Thanks Michael. You put me on the right track, though. :-)

--
Martin A. Weinberger
ButterflyVista
http://www.butterflyvista.com/


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com