Using Back button, page is "out of date".How to av
Posted: Sun Jun 29, 2003 4:46 am
Hi
i can't understand how to realize a simple script that allows to go back and "remember" the previous state after i sent some variables with a script. In many sites i see pages that (apparently, but i could be wrong since i am a newbie) call themselves after submitting a form but if i press back i can actually see the page where i was before, maybe with some out of date infos.
So what's wrong with this little code ?
Choose:<br />
<select name = "choice">
<option value = "yes">YES</option>
<option value = "no">NO</option>
</select>
<input type = "submit" value = "Send">
</form>
When I press "back" button it says the page is "out of date" (well, i don't know the precise sentence in english ) because some info were sent through a form. It says "press reload" but then the visit number has of course increased of 1.
Is it possible to accomplish a real "step back" to see a previous page ?
thankx a lot !
Wentu
i can't understand how to realize a simple script that allows to go back and "remember" the previous state after i sent some variables with a script. In many sites i see pages that (apparently, but i could be wrong since i am a newbie) call themselves after submitting a form but if i press back i can actually see the page where i was before, maybe with some out of date infos.
So what's wrong with this little code ?
Code: Select all
<?php
session_start();
if(!isset($_SESSION['visit']))
{$_SESSION['visit'] = 1;}
else
{$_SESSION['visit']++;}
if(isset($_POST['choice']))
{
echo "This is visit number #",$_SESSION['visit'],"<br />";
echo "Last time you choosed:",$_POST['choice'],"<br />";
}
else
{
$_POST['choice'] = "yes" ;
}
echo'<form action = "',$_SERVER["PHP_SELF"],'" method = post>';
?><select name = "choice">
<option value = "yes"
Code: Select all
<?php if($_POST['choice'] == "yes") echo "selected"; ?><option value = "no"
Code: Select all
<?php if($_POST['choice'] == "no") echo "selected"; ?></select>
<input type = "submit" value = "Send">
</form>
When I press "back" button it says the page is "out of date" (well, i don't know the precise sentence in english ) because some info were sent through a form. It says "press reload" but then the visit number has of course increased of 1.
Is it possible to accomplish a real "step back" to see a previous page ?
thankx a lot !
Wentu