Jump to content

If Statement - Allowing only user with permissions to see


warrens0017

Recommended Posts

Hi everyone,

I need a little help with trying to figure out what I need to do. I am writing an IF statement that allowed only certain users can see. So what I am trying to do, in my DB i have it created that if you are going to have certain access, the value in the DB is set to '1' for true. What I need help with is seeing how I can write and IF statement that reads that value and allows the user to see it. 

This is the current code I have:

<?php

if (isset($_SESSION['id'])) {
     echo "Welcome";
} else {
     echo "You not logged in or don't have access.";
}

?>

With this code, anyone that logs in will be able to see it. What I want is another line of code that allows those with the value of  '1' in the DB to see it. I have tried many different ways of seeing if I can get it to work but it never does. It either always returned the value TRUE and reads the code or the value is FALSE; even if when I am login, the value turn FALSE.

So if anyone can give me just a quick moment of their time, that would be great.

NOTE: My DB Connection is in a header.

Link to comment
Share on other sites

I need to know what column do you have in your DB where the value is 1 and where you set the $_SESSION['id'] variable after login, after that i can help you further.

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...