Click to See Complete Forum and Search --> : [RESOLVED] Forbid user hitting back


valanto
03-28-2007, 09:15 AM
Hi,
I was wondering if there is a way in php or html or something to forbit the user from hitting back and going to the previous page and perhaps redirect them somewhere else or present them with an error page.

If there is a way, please tell me!:)
Thank you,
Valanto

MrCoder
03-28-2007, 09:31 AM
page1.php


<?
session_start();
define("THIS_PAGE", 1);

if(@$_SESSION['page'] > THIS_PAGE)
{
header("Location: page".(int)$_SESSION['page'].".php");
die();
}

$_SESSION['page'] = THIS_PAGE;
?>
<h3>This is page 1</h3>
<a href="page2.php">Goto page 2</a>


page2.php


<?
session_start();
define("THIS_PAGE", 2);

if(@$_SESSION['page'] > THIS_PAGE)
{
header("Location: page".(int)$_SESSION['page'].".php");
die();
}

$_SESSION['page'] = THIS_PAGE;
?>
<h3>This is page 2</h3>
<a href="page1.php">Goto page 1</a>(or click back)