Jump to content

If Statement - Allowing only user with permissions to see


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 post
Share on other sites
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...