pdo prepared语句在表字段中插入null,oop php

clj7thdc  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(409)

我正试图创建一个面向对象的登录系统,却被困在了这个系统上
苏,这是我的课

include_once 'db.php';

class loginHandler extends db {

    private $login;
    private $password;
    private $email;
    private $stmt;

    public function __construct ($l,$p,$e) {

        $this->login = $l;
        $this->password = $p;
        $this->email = $e;
        $this->stmt = $this->connect()->prepare("INSERT INTO users (log,pwd,email) VALUES (?,?,?);");

    }

    public function send () {

        $this->stmt->execute([$this->login,$this->password,$this->email]);

    }

}

这就是提交按钮的位置

include 'loginHandler.php';

$log = $_POST['log'];
$pwd = $_POST['pwd'];
$em = $_POST['email'];

$buffer = new loginHandler ($log,$pwd,$em);
$buffer->send();

因此,当它运行时,表字段将填充“null”,而不是来自输入的实际数据

5sxhfpxr

5sxhfpxr1#

您需要在发布前添加$符号

$log = $_POST['log'];
$pwd = $_POST['pwd'];
$em = $_POST['email'];

相关问题