我有以下代码:
<?php
if(!empty($_POST)){
$db = new mysqli('localhost', 'root', '', 'verif1');
$password = $_POST['pass'];
$username = $_POST['user'];
$table = "admins";
$password = hash("sha256", $password);
$statement = $db->prepare("SELECT COUNT(*) FROM {$table} WHERE username = ? AND password = ?");
$statement->bind_param("ss", $username, $password);
$statement->execute();
$statement->bind_result($numrows);
if($numrows == 1){
echo "yeah correct!<br>";
}else{
echo "No :(<br>";
}
}
?>
<form action="" method="POST">
<input type="textbox" name="user">
<br>
<input type="password" name="pass">
<br>
<input type="submit">
</form>
我确信一切都是正确的(没有错误抛出,什么都没有)它只是不起作用!我尝试 print_r() 来查看已返回的反对,我得到了这个:在 execute() 之后我这样做:
print_r($statement);
die();
它给了我这个:
mysqli_stmt 对象 ( [affected_rows] => -1 [insert_id] => 0 [num_rows] => 0 [param_count] => 2 [field_count] => 1 [errno] => 0 [error] => [error_list] =>数组 () [sqlstate] => 00000 [id] => 1)