尝试使用登录系统简化网站,但我的一个代码文件的准备语句中显示错误。
由于我对这种形式的代码还很陌生,所以我不确定如何解决这个问题。我不太明白错误信息。
这是我的代码:
<?php
class Signup extends Dbh {
protected function setUser($uid, $pwd, $email) {
$stmt = $this->connect()->prepare('INSERT INTO users (users_uid, users_pwd, users_email) VALUES (?, ?, ?);');
$hashedPwd = password_hash($pwd, PASSWORD_DEFAULT);
if(!$stmt->execute(array($uid, $hashedPwd, $email))) {
$stmt = null;
header("location: ../index.php?error=stmtfailed");
exit();
}
$stmt = null;
}
protected function checkUser($uid, $email) {
$stmt = $this->connect()->prepare('SELECT users_uid FROM users WHERE users_uid = ? OR users_email = ?;');
if(!$stmt->execute(array($uid, $email))) {
$stmt = null;
header("location: ../index.php?error=stmtfailed");
exit();
}
$resultCheck;
if($stmt->rowCount() > 0) {
$resultCheck = false;
}
else {
$resultCheck = true;
}
return $resultCheck;
}
}
?>
这是错误信息:
致命错误:未捕获错误:调用未定义的方法 SignupContr::prepare() 在 /storage/ssd1/276/20299276/public_html/class/signup.classes.php:20
堆栈跟踪:
#0 /storage/ssd1/276/20299276/public_html/class/signup-contr.classes.php(101): 注册->checkUser('123', '[email protected]')
#1 /storage/ssd1/276/20299276/public_html/class/signup-contr.classes.php(39): SignupContr->uidTakenCheck()
#2 /storage/ssd1/276/20299276/public_html/includes/signup.inc.php(19): SignupContr->signupUser()
#3 {main} 扔在 /storage/ssd1/276/20299276/public_html/class/signup.classes.php 上 20" 号线
[123只是一个随机输入来测试]