if you want something pretty simple yet effective use something like:
PHP Code:
<?php
$referer = $HTTP_REFERER;
if($referer != "")
{
$link = "<a href='".$referer."'>Back</a>";
}
else
{
$link = "<a href='#' onClick='history.go(-1)'>Back</a>";
}
?>
If a referer is there, then use that else, attempt to use browsers back button. Should help you some of the time