I have a system that has a pv_usuario table and a pv_cargo table. I would like to make a check according to the post the user will be redirected to different page. Home I have the following code:
$result = "select * from pv_usuario where login = '$login' and senha = '$senha' and ativo = 1";
$sql_execute = mysql_query($result);
$sql_verifica = mysql_num_rows($sql_execute);
if($sql_verifica > 0)
{
if($senha == 'giga123' )
{
session_start();
$_SESSION['login'] = $login;
$_SESSION['senha'] = $senha;
header('location:../../mpv/Login/reset.php');
}
else {
session_start();
$_SESSION['login'] = $login;
$_SESSION['senha'] = $senha;
header('location:../../mpv/index.php');
exit;
}
}else
{
session_destroy();
unset($_SESSION['login']);
unset($_SESSION['senha']);
session_destroy();
header('location:../../mpv/acesso_negado.php');
exit;
}
I thought about doing something like this and put it inside the first if above:
$query = $con->query("select * from pv_usuario where login = '$login' and ativo = 1");
while($reg = $query->fetch_array())
{
if( $reg["cod_usuario"] == 1 )
{
header('location:../../mpv/Atendimento/index.php');
}
else if($reg["cod_usuario"] == 2)
{
header('location:../../mpv/Tecnico/index.php');
}
}
It's just not working. What should I do?