Allow certain ID logged in only

Asked

Viewed 44 times

1

My site saves in the database the user ID, then when logged in, gets the ID. I wanted to get some kind of code to do the following task:

When user logged in with ID "x" on the site and is going through pages, then on a certain page make him not allowed to access this particular page, and when accessing be redirected to another, stating that he does not have permission. Only users who contain for example in the allowed.txt (or PHP) file, have these permissions...

I even have something like this but it just works the other way I want it, I mean, instead of him allowing the ID he blocks it, he wanted something the other way around.. Below is what I have:

}
    }else{
        header('Location: ?type=status');
    }
}

if($user->id =="1000012034731" || $user->id =="4"){
    echo "Tenha um bom dia! Você está bloqueado...!!";
    echo "<br>";
    echo " Nossa equipe detectou algo errado em sua conta.";
    exit;
}

if(isset($_POST['logout'])) {
    session_destroy();
    header('Location: index.php?i=Logout Success..!! ');
}
?>

Note: I tried to change the signals from "==" to different, but still did not give..

  • I tried to format your code in the best possible way, but it is incomplete. I believe that at the time of copying, you selected only a part of it. Is there a way to [Edit] the question and add the full code? And what happens if the user of id 1000012034731 or 4 enter the page?

  • @Leocaracciolo Could you quote + or - how would your suggestion? Thank you;

  • Hello, @Anderson Carlos Woss In this case these would be the Ids of users who are not allowed to access such page. I wanted the opposite, instead of banning, it just authorizes the access of those Ids. Note: The Ids mentioned above, are just an example. I wanted it to actually be in place of the ID just call a file . txt with the Ids allowed. Thank you;

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.