I created a basic login with php
for the site I'm developing, but when trying to log in, the following error occurs: "invalid user or password" , this error is in the code, but I do not understand why it happens, since I already checked the bank's data, such as user, password and bank name, they are all correct.
My code looks like this:
login.php
<?php
$cnpj = $_POST['cnpj'];
$senha = $_POST['senha'];
$conexao = mysqli_connect('localhost','root','');
$db = mysqli_select_db($conexao, 'treinamentos') or print(mysqli_error());
$sql = "SELECT * FROM usuario WHERE cnpj = '$cnpj' AND senha = '$senha'";
$resultado = mysqli_query($conexao, $sql);
if (mysqli_num_rows($resultado) == 0) {
echo "Usuário ou senha não conferem" ;
echo '<br><br><a href="../index.html">Voltar</a>';
session_destroy();
}else {
header("Location:index.html");
}
?>
html form
<form method="POST" action="php/login.php">
<div class="row form-group">
<div class="col-md-12">
<label for="username">CNPJ</label>
<input type="text" class="form-control" id="cnpj" name="cnpj">
</div>
</div>
<div class="row form-group">
<div class="col-md-12">
<label for="password">Senha</label>
<input type="password" class="form-control" id="senha" name="senha">
</div>
</div>
<div class="row form-group">
<div class="col-md-12">
<input type="submit" class="btn btn-primary" value="Acessar" id="acessar" name="acessar">
</div>
</div>
</form>
If you have an idea of what might be causing such an error, I appreciate any help.