I'm having a problem with my bd query. I want to make a login page with the following form:
<form method="post" action="Login.php">
Email:<br>
<input class="form-control" placeholder="Seu email" type="text" name="email">
<br>
Senha:<br>
<input class="form-control" type="password" placeholder="Sua senha" name="senha">
<br>
<input type="submit" class="btn btn-embossed btn-info" name="Entrar" value="Entrar">
</form>
And use the Login.php page:
<?php
//Conectando ao banco de dados
$mysqli = new mysqli("localhost", "root", "", "authenticationteste");
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (".$mysqli->connect_errno.") ".$mysqli->connect_error;
}
//$nomeUser = $_POST["nomeUser"];
$email = $_POST["email"];
//$senha = $_POST["senha"];
//Consultando banco de dados
$res = $mysqli->query("SELECT senha FROM login WHERE email='".$email."';");
//email não encontrado
if (!$res) {
echo "Query failed: (".$mysqli->errno.") ".$mysqli->error;
}
However, when I put any information in the email label, the loop always returns me ENTROU, (even if it is not registered in the database). I've done a test to display the variable coming from the post method, and it gets exactly what I wrote in the field, but at the time of the database query, that value is not used. I have tried many ways, but the query never works. This is the first time something like this happens with my code, so if you can help I appreciate it.
I repeat: The post method is working, it stores in the variable correctly. the problem is time to use it in the query.
Thank you!