Good afternoon I did a system, bd ok and loguin check ok but I wanted it after checking the user it opened the right page for the right user example: I have 3 levels being them 0 1 2 and I want the level 0 user to open the page index1.php or user level 1 open the page index2.php and the user level 2 open the page index3.php
<?php
session_start(); // Inicia a session
include "config.php";
$usuario = $_POST['usuario'];
$senha = $_POST['senha'];
if ((!$usuario) || (!$senha)){
echo "Por favor, todos campos devem ser preenchidos! <br /><br />";
include "index.html";
}else{
$senha = md5($senha);
$sql = mysql_query(
"SELECT * FROM xxxxxx_usuarios
WHERE usuario='{$usuario}'
AND senha='{$senha}'
AND ativado='1'"
);
$login_check = mysql_num_rows($sql);
if ($login_check > 0){
while ($row = mysql_fetch_array($sql)){
foreach ($row AS $key => $val){
$$key = stripslashes( $val );
}
$_SESSION['usuario_id'] = $usuario_id;
$_SESSION['nome'] = $nome;
$_SESSION['sobrenome'] = $sobrenome;
$_SESSION['email'] = $email;
$_SESSION['nivel_usuario'] = $nivel_usuario;
mysql_query(
"UPDATE xxxxx_usuarios SET data_ultimo_login = now()
WHERE usuario_id ='{$usuario_id}'"
);
header("Location: separador.php");
}
}else{
echo "Você não pode logar-se! Este usuário e/ou senha não são válidos!<br />Por favor tente novamente!<br />";
include "index.html";
}
}
?>
this is the separator.php file
<?php
$nivel = $_SESSION['nivel_usuario'];
if ($nivel == 0){
header("location: /NORMAL/inicio.html");
} else if ($nivel == 1){
header("location: /PREMIUM/index.html");
} else if ($nivel == 2){
header("location: /ADM/index.html");
} else {
header("location: index.html");
}
?>