Page 1 of 1

$_POST keys are persisted...

Posted: Wed Apr 14, 2004 2:23 pm
by davidklonski
Hello guys

I am using IE6.0 and I am running into a small problem.
I wrote a simple form in page.php:

Code: Select all

<?php
   if (isset($_POST['txt'])) {
      echo 'txt is already set<br>';
   }
?>
<form name='x' method='post' action='page.php'>
  <input type='text' name='txt'>
  <input type='submit' value='go'>
</form>
Note that I am using post as the method
Also note that I am sending the information to the same page.

For some reason (and maybe this is the right behaviour), when I refresh this page, I always get the line: "txt is already set" printed.

Doesn't the browser clean up all the $_POST keys when the page is reloaded? If not, how do I cause it to do it?
The same behaviour happens when I go from page.php to another page and clicks 'back' in the browser.
Is there a way to cause the browser to start the page with a clean $_POST array?

Note the since the form sends the info to the same page there is a case where I need those keys in the $_POST array.

thanks in advance and sorry about the lack of browser-related knowledge.

Posted: Wed Apr 14, 2004 2:25 pm
by d3ad1ysp0rk
When you refresh the browser asks you if you'd like to resend the data.

Posted: Wed Apr 14, 2004 2:27 pm
by davidklonski
this is true, but even if I click 'cancel' I return the page and the keys are there in the $_POST array...

Posted: Wed Apr 14, 2004 2:34 pm
by d3ad1ysp0rk
"Cancel" cancels the actual refresh.

So it reverts to the page that was loaded.

Posted: Wed Apr 14, 2004 2:41 pm
by davidklonski
once I submit the form to the page, the browser remembers the $_POST keys and no matter what I do, I cannot cause isset($_POST['txt']) to return false...
what can I do.

I have seen web sites that display:
Warning: Page has Expired The page you requested was created using information you submitted in a form. This page is no longer available. As a security precaution, Internet Explorer does not automatically resubmit your information for you.

To resubmit your information and view this Web page, click the Refresh button.

how come my page doesn't do that?