With using conditions within a PHP method

Asked

Viewed 37 times

0

I already ask forgiveness for some kind of mistake in the creation of the question, I am willing to receive help

I have a login using classes that after logging in the user, who is saved in the BD, after logging in the level of the logged in user is verified because the 3 levels of privileges in the program q do

  1. Administrator
  2. Professor
  3. Pupil

I want to limit some of these users to using only a few functions. But the program only runs is 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>";
        }
  • 4

    $nivel=2 is an assignment within the if.

1 answer

2


Replace the operator = for ==, within the if.

...
if ($nivel == 2) {
...
  • Then on some changes to the $_SESSION q I was using and with YOUR tip, I got it. Thank you my dear.

Browser other questions tagged

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