2
Hello guys I’m beginner in php and I’m having a difficulty have a table of users (id, login, password, level) according to the level of the user should go to a different panel, the login part this ok, only the level value cannot assign to a variable to make a comparison and direct the user to its due panel
follows 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>";
}
its $nivel = 0; is always equal to 0
– Amadeu Antunes
Good morning Thanks for proposing to help I assign zero I see if in the code below it would change value, if I change manually the value of $nivel = 1; it runs the script straight and redirects... But this value I already have in the bank and I can not recover it and assign to $nivel understood I found some things on the web but they did not work, maybe I have implemented wrong
– Ivair Izidoro