make the login button a link that passes the current page name as a querystring variable to the login page:
<a href="login.php?accesscheck=<?php echo((isset($_SERVER["PHP_SELF"]))?$_SERVER["PHP_SELF"]:"") ?>">Log in</a>
the login behavior should use the accesscheck url variable as the redirect location.