Edit: What I really need to know is if there is any javascript event that will reliably fire when the user arrives at the page via the back button. I trie
The answer by @tkotitan was probably correct when he wrote it. His answer led me to my solution. It's not foolproof, but it might be "good enough" to help in some situations.
I improved my script and replaced it with the following. This version is for an intermediate page that now works as intermediate in both directions.
Go forward';
}
elseif($_GET['page']!=2)
{
echo 'You cannot stay here.';
echo '

';
}
else
{
echo 'Welcome to page 2';
}
?>