我正在尝试对页面登录进行编码,但在此错误中我处于停止状态
PLIZ在这里告诉我错了事
<?php @session_start(); include("../../connexion/connexion.php"); class login_class { public $user; public $password; public $connexion; public function check_login() { try { $cn = new class_connect(); $this->connexion = $cn->connect(null); $result = $this->connexion->execute("select * from user where username='$this->user' and password='$this->password'"); $data = $result->fetchAll(PDO::FETCH_OBJ); if (!empty($data[0]->id_user)) { return true; }else { return false; } }catch(PDOException $ex) { echo $ex->getMessage(); } } public function __construct($user) { if($user){ $this->user = $user["username"]; $this->password = $user["password"]; } } } ?>
->execute()用于准备的语句。例如
->execute()
$stmt = $dbh->prepare('some query here'); $stmt->execute();
您正在尝试直接在主数据库对象上执行查询。对于PDO,这意味着
$dbh->exec('query goes here');
您确实应该研究准备好的语句。您很容易受到SQL注入攻击的影响,并且由于您从一开始就使用PDO,因此不编写安全查询基本上是不可原谅的。