This question already has an answer here:
I have a login page that redirects to this set of PHP code:
<?php
$mysql_host = "***";
$mysql_database = "***";
$mysql_user = "***";
$mysql_password = "***";
$conn=mysqli_connect($mysql_host, $mysql_user, $mysql_password, $mysql_database);
if (mysqli_connect_errno($conn))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$email = $_POST["email"];
echo $email;
$password = $_POST["pass"];
echo $password;
$stmt = $conn->prepare("SELECT email, password FROM account WHERE email = ?");
$stmt->bind_param("s", $email);
$stmt->execute();
$stmt->bind_result($mail, $pass);
echo $stmt;
echo $mail;
echo $pass
if ($pass === $password and $password != null)
{
echo "Logged in";
} else {
echo "Unsuccessfull";
}
?>
When I run it with the test values in my database I get these messages:
random@sample.com
password
SELECT password FROM account WHERE email = random@sample.com
Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in /home/a3996154/public_html/login.php on line 22
Unsuccessfull
Aucun commentaire:
Enregistrer un commentaire