慢慢习惯了PHP准备好的语句,但是仍然出现此错误
“警告:mysqli_stmt :: bind_result():绑定变量的数量与C:\ Users \ PC \ Documents \ XAMPP \ htdocs \ login.php的第20行中准备好的语句中的字段数不匹配。”
<?php
$mysqli = new mysqli('localhost', 'c3337015', 'c3337015', 'members');
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if(isset($_GET['loginEmail'])){
session_start();
$stmt = $mysqli->prepare("SELECT Email FROM members WHERE Email=? AND Password=? LIMIT 1");
$email = $_GET['loginEmail'];
$password = $_GET['loginPassword'];
$password = sha1($password);
$stmt->bind_param('ss', $email, $password);
$stmt->execute();
$stmt->bind_result($email, $password);
$stmt->store_result();
if($stmt->num_rows == 1) //To check if the row exists
{
while($stmt->fetch()) //fetching the contents of the row
{$_SESSION['Logged'] = 1;
$_SESSION['Email'] = $email;
header('Location: index.php');
exit();
}
}
else {
echo "Wrong Username or Password!";
}
$stmt->close();
}
else
{
echo "Something went Wrong";
}
$mysqli->close();
?>
$stmt->bind_result($email, $password);