Professional Web Applications Themes

Expiring $_POST variables - PHP Development

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

  1. #1

    Default Expiring $_POST variables

    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/


    Martin Guest

  2. #2

    Default Re: Expiring $_POST variables

    Martin A. Weinberger wrote: 

    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
    Michael Guest

  3. #3

    Default Re: Expiring $_POST variables

    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/


    Martin Guest

Similar Threads

  1. Session variables expiring
    By mohadi in forum Coldfusion Server Administration
    Replies: 6
    Last Post: August 1st, 12:18 PM
  2. Expiring Session Variables
    By umuayo in forum Coldfusion - Getting Started
    Replies: 3
    Last Post: April 20th, 03:57 PM
  3. Help with $_POST variables. Reading their names.
    By Sugapablo in forum PHP Development
    Replies: 4
    Last Post: November 26th, 05:55 PM
  4. [PHP] dump $_POST into variables????
    By Joe Harman in forum PHP Development
    Replies: 1
    Last Post: July 13th, 02:58 PM
  5. dump $_POST into variables????
    By Joe Harman in forum PHP Development
    Replies: 0
    Last Post: July 11th, 05:01 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139