Using conditions within a method in PHP

0

Since I apologize for some kind of error in creating the question, I am willing to receive help

I have a login using classes that after logging in the user, which is saved in the DB, after being logged in the logged user level is checked because the 3 levels of privileges in the program I do

  • Admin
  • Teacher
  • Student
  • I want to limit some of these users to using only certain functions. But the program only runs this line.

    public function Menu($nome, $nivel) #CRIAÇAO DOS MENUS DE ACORDO COM O NIVEL DO USUARIO.
        {
    
    
    if($nivel=2){
            echo "<html lang='pt-br'>
        <head>
        <meta charset='utf-8'/>
        <title>Página inicial</title>
        <link rel='stylesheet' type='text/css' href='css/style.css' />  
        </head>
        <body >
        <div class='menu-container'>
        <ul class='menu clearfix'>
           <li><a href='?inicio'>Início</a></li>
            <li><a href='?disciplinas'>Disciplinas</a>
            ".
                        "
        </li>
        <li><a href='?salas'>Salas</a></li>
    
        <li><a href='?usuarios'>Usuários</a></li>
    
        <li><a href='?perfil'>$nome</a></li>
        <li><a href='?sair'>Sair</a></li>
    </ul>
    </div>
    </body>
    </html>";
            }
    
        
    asked by anonymous 20.02.2018 / 20:49

    1 answer

    2

    Replace the = operator with == , within if .

    ...
    if ($nivel == 2) {
    ...
    
        
    20.02.2018 / 21:49