warrens0017 Posted May 22, 2017 Share Posted May 22, 2017 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 More sharing options...
justsomeguy Posted May 22, 2017 Share Posted May 22, 2017 Where are you setting the session information? We need to see all of that code if there's a problem with it. Are you starting the session on every page? Link to comment Share on other sites More sharing options...
Gabrielphp Posted May 23, 2017 Share Posted May 23, 2017 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 More sharing options...
integral Posted May 31, 2017 Share Posted May 31, 2017 What type of variable is 'id' in your DB. if its numeric then a value of zero will also make your If valid Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now