Problem when reloading PHP page
Posted: Mon May 02, 2011 8:12 pm
I noticed something bothersome when I have a page that whose text fields are are filled data retrieved from POST. This is fine, but when the user suddenly opts to press <enter> in the address bar, the page reloads but this time without the posted data, so kinda messing things up. If the user reloads the page with the refresh button things are ok. This is in firefox.
Here's a simple example to illustrate. This is the form portion of a page that will POST to test.php:
Then here's test.php which retrieves the POST and prints them.
All works fine. But after test.php loads properly, if the user chooses to press <enter> on the address bar which has http:localhost/.... test.php, it reloads test.php but this time without the POSTed data.
Here's a simple example to illustrate. This is the form portion of a page that will POST to test.php:
Code: Select all
<form action="test.php" method="post">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
Code: Select all
Welcome <?php echo $_POST["fname"]; ?>!<br />
You are <?php echo $_POST["age"]; ?> years old.