create the login link with an accesscheck querystring variable that passes the current page, the login will use the access check page as the success redirect if it exists:
<a href="login.php?accesscheck=<?php echo(urlencode($_SERVER['PHP_SELF'])); ?>">Log in</a>