Hi,

This may be real dumb, but is it possible to destroy the $_POST array like you can with the session array?

I've tried $POST=array(); but it doesn't work like $SESSION=array(); does.

Any pointers?

Thanks!

    I'm stumped, because that's always worked for me and still does. What's the code it's in look like?

      I don't get it then!

      My idea was to kill off the post array so that a user couldn't refresh the page and resubmit the info.

      A form gets submitted, the $POST vars are added to the database (firstName, secondName, password etc) and then right at the end I have $POST = arrray();

      Now when I refresh the browser, the $_POST vars are still there. Should they be?!?

      Using IE 6 if that makes a difference. I know it had problems with some session headers or something a while back.

      😕

        I think that when you refresh the page, you're just resending the same information as when you opened it the first time, i.e. the browser cached it and is reusing it. I may be wrong.

        ecit: I'm using IE6, also.

          Originally posted by Installer
          I think that when you refresh the page, you're just resending the same information as when you opened it the first time, i.e. the browser cached it and is reusing it. I may be wrong.

          You are not. When you refresh your browser, your broswer asks you if you want to resubmit the POST data. If you say ok/yes, it reconnects to your script and sends the same set of data to the server. Trying to destroy the $_POST array at the end of a script is pointless.

            So there's no way of stopping a refresh>resubmit scenario then?

              Originally posted by webnewone
              So there's no way of stopping a refresh>resubmit scenario then?

              Yes, there is. You will need to have your form submit to some script which processes the form data but has no output. That script will then need to redirect to another page (via header('Location: blah.php') or javascript redirects) that tells the user what happened. For example:

              # page1.html
              <form action="form_process.php" method=POST>
              <input type=text name='blah''
              <input type=submit value="Go">
              </form>
              <?
              # form_action.php
              $blah = $_POST['blah'];
              // process $blah
              header('Location: page2.php?result=Good');
              ?>
              <?
              # page2.php:
              echo $_GET['result'];
              ?>

              When the user submits the form on page1.html, they wind up on page2.php. If they refresh this page, the same output is displayed and nothing is processed again. HTH.

                use unset($variable) instead

                  Write a Reply...