samedi 16 octobre 2021

IF statement won't take more than 2 conditions

I'm setting up a system where if a users group number is present the user will have access to the page. For example I want people in group 7,8, and 14 to have access to the page. This works fine for the users in group 7 and 8 but if the user is group 14 access appears to be denied. Here's what I tried so far I tried to go this two ways but to no avail. Any help would be appreciated.

An if statment with more than two conditions.

if ($_SESSION['userrole'] == 8 || $_SESSION['userrole']== 7 || $_SESSION['userrole']== 14) {
//text 
}else{
echo "access denied";

An array that have values to check against

$acc = array("8","7","14");
    if (in_array($_SESSION['userrole'],$acc)){
//text 
}else{
echo "access denied";

Aucun commentaire:

Enregistrer un commentaire