我面临的错误,不确定我的代码有什么问题。 致命错误:未捕获错误:在C:\ xampp \ htdocs \ 1605966I \ SGPFOOTPRINTS \ processLogin.php:25布尔值上调用成员函数bind_param()的堆栈跟踪:#0 {main}抛出在C:\ xampp \ htdocs \ 1605966I \ SGPFOOTPRINTS \ processLogin.php第25行强文本
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div id="header">
<h1> <img src="images/footprints.jpg "> Singapore Footprints</h1>
</div>
<div id="nav">
<?php
$userid = $_POST['username'];
//$password will store whatever the user typed in
$password = $_POST['password'];
//insert your database codes
$mysqli = new mysqli("localhost","root",null,"forumdb");
//replace the userid=? with either jon or mary, whatever user typed in to userid
$stmt = $mysqli->prepare("select password from forumuser where userid=?");
//going into $userid into the ? slot (NO NEED bind_param if there is no ?)
$stmt->bind_param("s",$userid);
//return password but not labelled
$stmt->execute();
//creating a variable, $p then password will be contained inside $p (NO NEED if there is no select)
$stmt->bind_result($p);
//MUST fetch, if not $p is empty therefore fetching "sad" the password that user typed in into $p
$stmt->fetch();
if ($p==$password){
echo "Welcome! You have logged in successfully! <br> <br>";
echo "Please <a href='comments.html'>Click Here</a> to continue <br> <br>";
//userid
//echo "<a href=messages.php?userid=$userid>Go to my messages</a>";
}
else{
echo "Unsuccessful login";
}
$stmt->close();
$mysqli->close();
?>
</div>
<div id="footer-push">
</div>
<div id="footer">
Copyright © School of IIT
</div>
</body>
</html>