Levels of login access

Asked

Viewed 85 times

0

How can I make it only show to the user who is with $cargo == 'Administrador'?

I saw many being used with number, but I want to leave registered with name Administrator or Visitor and so in the menu, get it shown only to the user who is in charge Administrator.

It would be something like that?

<?php
if($cargo == "Administrador"){
?>
        <li>
          <a href="?p=inicio">
            <i class="fa fa-home"></i> <span>Inicio</span>
          </a>
        </li>
<?php
    }
?>
  • And how are you assigning a value to the variable $cargo to compare with Administrador?

1 answer

3


I will explain to you quickly and objectively in right text?

When validating the login, you will probably bring among the results of the query, the username and the field you are using to assign the access level, check?

Store them in one $_SESSION, in such a way that it can do so whenever necessary and grant or deny access.

Your example is correct, just need to implement something in the sense I suggested.

Browser other questions tagged

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