I am getting confused by PHP at this point. I am trying to make a membership site but need a way to protect all my pages from unauthenticated access. Can someone steer me how to do this through PHP? I already have the database that does create accounts but once the account is created people can access the page as long as they know the full URL.

7 Years
Discussion Span
Last Post by diafol

Have you searched this site or the internet for login scripts? You'll find a few thousand. Just research.


But I notice that all of them just have a single user/pass to protect each page. I am looking for a php script that connects to the database with members before connecting the page to make sure that they are authenticated.


On form login - send details to a form handler file. Verification takes place, a session variable is set if user exists with details like username, userlevel. A paage redirect then occurs - usually back to the index page.

The index page shows different data, depending on whether the session variables are set or not or at which level the user is.

Each page should be 'protected' by the userlevel. Access to some, not others maybe or different views depending on level.

Votes + Comments
useful post

My problem is that I do not know how to write the code needed for the protection for individual pages. If I knew how to write the code, I would not have had to ask how to do it in this forum.


That's why you need to research it first. You can't expect members to write the code for you. Get a script, read the documentation and give it a go.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.