1
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 on the label of the email, the loop always returns me ENTERED, (even if it is not registered in the bank). I already made a test to display the variable coming by the post method, and it receives exactly what I wrote in the field, but at the time of the query to the bank, this value is not used. I’ve tried many ways, but the consultation never works. This is the first time something like this has happened with my code, so if you could help me,.
I repeat: The post method is working, it stores in the variable correctly. the problem is time to use it in the query .
Thanks!
Any error message appears?
– rray
no, none, apparently it works
– Rafa Zanezi
Has to be mysqli? mysql does not work?
– Diego Moreira
Var_dump() $mysqli->connect_errno : var_dump($mysqli->connect_errno); before if
– Diego Moreira
do you want to take the password? need a
fetch_array/fetch()
– rray
@Diegomoreira with var_dump($mysqli->connect_errno); returned int(0)
– Rafa Zanezi
Yeah! In class function syntax, you can and should use simple quotes, crase does not work, break code when you run. What has to be done is a fetch_array, as @rray said. So you have access to the query return.
– Diego Moreira
I recommend this link: https://secure.php.net/manual/en/mysqli-result.fetch-array.php
– Diego Moreira
What you need, as a better example, you can use this: http://answall.com/questions/50919/howto get dates-de-um-select-mysqli-get-e-sent-by-newsletter I hope you get, abs
– Diego Moreira
put $result = mysqli_fetch_array($email); and it returned: Warning: mysqli_fetch_array() expects Parameter 1 to be mysqli_result, string Given in...
– Rafa Zanezi