Jump to content

Assigning a value to a hidden message


9three

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.