Redirect To Previous Page after login
I have a comment form that I only want logged in users to be able to use. I found this code:
<a href="commentlogin.php?accesscheck=<?php echo((isset($_SERVER["PHP_SELF"]))?$_SERVER["PHP_SELF"]:"") ?><?php echo((isset($_SERVER['QUERY_STRING']))?"?".$_SERVER["QUERY_STRING"]:"") ?>">Log in</a>
on a previous post, which I put on the page that I have the form and it takes you to the commentlogin.php with the previous page's url and variables. How do I use this on my commentlogin.php page so that it takes you back to that page when you've logged in. I captured the url as a session variable and put it in the redirect script but it just takes me back to my home page.
Here is my login page. You can find the form down near the bottom of this page... blog_life_and_times_of_the_man_of_steel.html