Hello everyone, I'm new to php and I'm having a hard time getting a user table (id, login, password, level) according to the level of the user should go to a different panel, the login part is ok, only the level value I can not assign to a variable to make a comparison and direct the user to their panel
follow the code:
<?php
$usuario = $_POST['user'];
$senha = $_POST['password'];
$sql = mysql_query("SELECT * FROM db_usuarios WHERE login = '$usuario' and senha = '$senha'") or die (mysql_error());
$row = mysql_num_rows($sql) or die (mysql_error());
if($row == 1){
$nivel = 0;
$query = mysql_query("SELECT * FROM db_usuarios WHERE nivel = '$nivel'");
echo $nivel;
session_start();
$_SESSION['login'] = $_POST['user'];
$_SESSION['senha'] = $_POST['password'];
echo "<center>Login efetuado com Sucesso!!!</center> ";
//echo "<script>loginsuccessfully()</script>";
switch($nivel){
case 1:
echo "<script>diretor()</script>";
break;
}
}else{
echo "<center>Login ou senha invalidos aguarde um instante para tentar novamente!</center>";
echo "<script>loginfailed()</script>";
}