I'm trying to verify the existence of a user in the database when it logs in. The user and password are already created in the database, but even then the scan only enters else
.
logando.php
<?php
include_once("conexao.php");
session_start();
$usuario = $_POST['usuario'];
$senha = $_POST['senha'];
$result = mysqli_query("SELECT * FROM 'usuarios' WHERE 'usuario' = '$usuario' AND 'senha'= '$senha'");
if(mysqli_num_rows($result) > 0 )
{
$_SESSION['usuario'] = $usuario;
$_SESSION['senha'] = $senha;
header('location:teste1.php');
}
else{
unset ($_SESSION['usuario']);
unset ($_SESSION['senha']);
header('location:teste2.php');
}
?>
login.php
<?php
include_once("conexao.php");
session_start();
?>
<form class="login-form" name="loginform" method="post" action="logando.php">
<input type="text" placeholder="Usuário" name="usuario" required=""/>
<input type="password" placeholder="Senha" name="senha" required=""/>
<button type="submit">ENTRAR</button>
<p class="message"> Desenvolvido por: Marcos A. Massini</p>
</form>
<p class="text-center text-danger">
<?php
if(isset($_SESSION['loginErro'])) {
echo $_SESSION['loginErro'];
unset($_SESSION['loginErro']);
}
?>
</p>
connection.php
<?php
$servidor = "localhost";
$usuario = "root";
$senha = "";
$dbname = "cadastro";
$conn = Mysqli_connect($servidor, $usuario, $senha, $dbname) or print (mysql_error());
if(!Mysqli_connect($servidor, $usuario, $senha)) {
echo "Error ao conectar";
}
?>