0
in the system there are 2 user levels 1 = admin and 2 = helper, and after logging in need redirect each to a different page. This is my php code
<?php
session_start();
include('conexao.php');
if (empty($_POST['usuario']) || empty($_POST['senha'])) {
header('Location: index.php');
exit();
}
$senha = $usuario = $user_tipo = "";
$usuario = mysqli_real_escape_string($conexao, $_POST['usuario']);
$senha = mysqli_real_escape_string($conexao, $_POST['senha']);
$nivel = mysqli_real_escape_string($conexao, $_POST['nivel']);
$query = "select nome, usuario, nivel from usuario where usuario = '{$usuario}' and senha = md5('{$senha}')";
$result = mysqli_query($conexao, $query);
$row = mysqli_num_rows($result);
$redirecionamentos = [
'1' => 'usuarios.php',
'2' => 'downloads.php',
];
if (array_key_exists($_SESSION['nivel'], $redirecionamentos)) {
header('Location: ' . $redirecionamentos[$_SESSION['nivel']], true, 302);
}
if ($row == 1) {
$_SESSION['usuario'] = $usuario;
header($redirecionamentos);
exit();
} else {
$_SESSION['nao_autenticado'] = true;
header('Location: index.php');
exit();
}
And this error returns to me when I access
Not working? What was the error message? What are the latest messages in the server log file?
– Woss
Well it is not authenticating nor redirecting the type of user to the specific page,no log appears these errors[26-Dec-2018 13:56:18 UTC] PHP Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) in /home1/xopen037/public_html/Gob.logosassessoriaconsultoria.com.br/gobdowloads/conexao.php on line 8 [27-Dec-2018 12:41:25 UTC] PHP Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (password using: NO) in /home1/xopen037/public_html/Gob.logosassessoriaconsultoria.com.br/gobdowloads/conexao.php on line 8
– nathan
That is, the database connection failed. Check the connection data and make sure the database server is connected.
– Woss
i am doing the editing on wampserver local server, not on the online server
– nathan