Здравствуйте! При выполнении запроса выходит ошибка:
Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in C:\OSPanel\domains\localhost\models\UserModel.php on line 53
Но, после ошибки все таки появляется слово "Success", но к сожалению, даже после него в БД пусто. :с
class UserModel extends Db {
public $name, $surname, $avatar, $email, $password, $password_2, $gender;
public function __construct() {
$this->name = $_POST['name'];
$this->surname = "Uzumaki";
$this->avatar = "defautl.jpg";
$this->email = $_POST['email'];
$this->password = $_POST['password'];
$this->password_2 = $_POST['password_2'];
$this->gender = $_POST['gender'];
}
public function RegisterCheck() {
$errors = array();
if ( trim($this->name) == "" ) {
$errors = "Name";
}
if ( trim($this->email) == "" ) {
$errors = "E-mail";
}
if ( $this->password == "" ) {
$errors = "Password";
}
if ( $this->password_2 != $this->password ) {
$errors = "Password 2";
}
if ( trim($this->gender) == "" ) {
$errors = "Gender";
}
if ( empty($errors) ) {
$sql = $this->connect()->prepare("INSERT INTO `users` ('name', 'surname', 'email', 'password', 'avatar', 'gender') VALUES (:name, :surname, email, :password, :avatar, :gender)");
$sql->bindParam(':name', $this->name, PDO::PARAM_STR);
$sql->bindParam(':surname', $this->surname, PDO::PARAM_STR);
$sql->bindParam(':email', $this->email, PDO::PARAM_STR);
$sql->bindParam(':password', $this->password, PDO::PARAM_STR);
$sql->bindParam(':avatar', $this->avatar, PDO::PARAM_STR);
$sql->bindParam(':gender', $this->gender, PDO::PARAM_INT);
$sql->execute();
echo "Success";
} else {
echo $errors;
}
}
}