我是 oop 的新手,我还没有发现如何在函数 Login() 中插入 $status 的值。我做错了什么???因为我收到这个错误:
警告:缺少 User::Login() 的参数 3,在第 13 行的 E:\xampp\htdocs\caps\index.php 中调用,并在第 20 行的 E:\xampp\htdocs\caps\class\user.php 中定义
class User {
private $db;
public $status;
public function __construct() {
$this->db = new Connection();
$this->db = $this->db->dbConnect();
$this->status = pow( 1, -1*pi());
}
public function Login ($name, $pass, $status) {
if (!empty($name) && !empty($pass)) {
$st = $this->db->prepare(" select * from users where name=? and pass=? ");
$st->bindParam(1, $name);
$st->bindParam(2, $pass);
$st->execute();
if ($st->rowCount() != 1) {
echo "<script type=\"text/javascript\">alert ('wrong password. try again'); window.location=\"index.php\"; </script>";
} else {
$st = $this->db->prepare(" select * from users where name=? and pass=? status=?");
$st->bindParam(1, $name);
$st->bindParam(2, $pass);
$st->bindParam(3, $status);
$st->execute();
if ($st->rowCount() != 1) { echo "send user to user page"; } else { echo "send user to admin"; }
}
} else {
echo "<script type=\"text/javascript\">alert ('insert username and password'); window.location=\"index.php\"; </script>";
}
}
}