Forum Moderators: coopster
<?
if ($_SERVER[HTTP_REFERER])
{
header("Location: ".$_SERVER[HTTP_REFERER]);
}
?> This should work and also preserve the query string. If I clicked onto a page with the code above from /index.php?foo=bar, I will be redirected to /index.php?foo=bar
Is that not what you need to achieve?
Keep a session variable of the pages that are visited. Ex: $_SESSION['currentpage'] & $_SESSION['prevpage']. When a visitor goes from index.php?page=2 from index.php?page=1,?page=1 gets moved from 'currentpage' to 'prevpage' and?page=2 gets put into 'currentpage'. Then, just link to $_SESSION['prevpage'].