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
https://forums.phpfreaks.com/topic/180714-assigning-a-value-to-a-hidden-message/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.