Members Pages

I’m having a bit of difficulty getting a script to work that has a logged in user and lets the access member only pages,

E.G: when you first visit the page it has Home, F.A.Q, Clients, Login. I’d like for you to be able to login and see all of those, plus new client sheet, edit news, edit profile, etc, etc, etc, etc… I’ve got all of those pages set up and working, the only thing that isn’t working is the members only codes i’ve been trying to get working after scouring the interwebs for tutorials on the matter.

If you need any additional information about what I have been using, please ask.

Hello.

I think I understand what you are trying to do, I recommend using sessions for your users.
After they have logged in set a session like USERNAME or something. Then for your userpage(s) you can add this to check if they have access to view it:

[php]

if ($_SESSION[‘USERNAME’])
{
// No need to do anything
}
else
{
echo “You need to be logged in to view this page…”;
}

[/php]

Checks if they are logged in, if not, they see the error, you might want to use “die” instead of echo.

Hope this helps!

You have a successful login, so you know who the user is.
From that moment on you have the user information somewhere, Let’s call it $userinfo and it evaluates as ‘true’ only when the login was succesful.

Depending on how your application works you can build the check around the 'include’sup[/sup] for the page the client requested or insidesup[/sup] the page the client requested.

[sup]*(1)[/sup]
[php]if ( $userinfo )
{ include( $the_requested_page );
} else
{ include( “Sorry_NoRights.php” );
}
[/php]

[sup]*(2)[/sup]
[php]
if ( ! $userinfo )
{ return;
}
[/php]

Hope it helps. :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service