$_POST keys are persisted...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
davidklonski
Forum Contributor
Posts: 128
Joined: Mon Mar 22, 2004 4:55 pm

$_POST keys are persisted...

Post 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.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

When you refresh the browser asks you if you'd like to resend the data.
davidklonski
Forum Contributor
Posts: 128
Joined: Mon Mar 22, 2004 4:55 pm

Post by davidklonski »

this is true, but even if I click 'cancel' I return the page and the keys are there in the $_POST array...
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

"Cancel" cancels the actual refresh.

So it reverts to the page that was loaded.
davidklonski
Forum Contributor
Posts: 128
Joined: Mon Mar 22, 2004 4:55 pm

Post 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?
Post Reply