9three Posted November 8, 2009 Share Posted November 8, 2009 Hey, I'm running a PHP script to check whether the user is logged in or not. If the user is not logged in they are redirected to the login.php page. What I would like to do is redirect them to the PHP page but also grab the URL they were previously on and assign it to a hidden field in the login.php so that I can redirect them back to the page they were on while keeping the URL bar clean. Problem, I know that PHP cannot recognize a hash (ex www.example.com/#pageImOn) so I would need to grab the url through javascript instead of PHP. Does anyone know of a good method of accomplishing this? Any help would be appreciated it. Quote Link to comment https://forums.phpfreaks.com/topic/180714-assigning-a-value-to-a-hidden-message/ Share on other sites More sharing options...
Alex Posted November 8, 2009 Share Posted November 8, 2009 You can grab the hash through document.location.hash. But why would the page the user is on be a hash anyway, wouldn't it be another .php file? That makes more sense to me, and in that case you should use php session variables to store the name of the page they were on previous to login so once they're verified they can be redirected. Quote Link to comment https://forums.phpfreaks.com/topic/180714-assigning-a-value-to-a-hidden-message/#findComment-953452 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.