Login dialog lightbox style pop-up upon navigation to a members-only page on website

garyhoffmann used Ask the Experts™

I would like to solve the following scenario:  A user comes to a website that has some content that is for members only while other content may be open to the public.  When a user clicks a link that is members only, I would like to prompt them for their login information.

I would like this prompt to be a lightbox style dialog (i.e. over the current page, darkened background that still shows the current page but a login box in the middle of the window).  I want to ensure they can not get to the other pages until they have successfully logged in.

I'm drawing a complete blank on how to do this.

The site is a (generally speaking) PHP/MySql site.

I'm assuming I have to do something with javascript as this will need to occur "after" the current page is loaded as this will occur when a link is clicked.  I also want to make sure it's only when a member-only link is clicked, not whenever the user tries to navigate away from the page.

Any thoughts on how to do this?

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Try this. Please note that you must this check if the user is logged in when the user accesses a protected page.

you need to add a listener to the hyper links and null the normal action (also point them to a false link) when they are not logged in, when the user clicks on the link it initialises the login box, then when the user has logged in modify the link code via the DOM so they point to the correct location and remove the listener.

Also I would check that users that do get to the secure site are redirected to the login page if they are not logged in.

I would advise using JQuery to do this action.



This is exactly the type of response I was hoping for - your sample page gives me everything I need to finalize all the details of this.

Thank you so much for such a thorough example.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial