The JavaScript method mentioned above will work for many users, but is not considered accessible for people with disabilities because of its reliance on client-side scripting.
With PHP, you can create a simple "back" link using the following code:
<?php
echo "<a href=\"";
echo $_SERVER['HTTP_REFERER'];
echo "\">back</a>";
?>
This will work for more users, even those who disable JavaScript out of security concerns or to get rid of annoying pop-up windows (globally about 10% of users).
Cheers!
-Andrew