我正在编写此代码,但是我遇到了这个错误,我已经尝试了多种修复方法,但是我无济于事?
我希望它将html中的注册表单中的数据插入数据库并将我转换为个人资料页面
class Users{
// database connection and table name
private $conn;
private $table_name = "users";
public $ID;
public $firstName;
public $lastName;
public $email;
public $user_type;
public $password;
// constructor with $db as database connection
public function __construct($conn){
$this->conn = $conn;
}
function create(){
// query to insert record
$query = "INSERT INTO
" . $this->table_name . "
SET
firstName=:firstName ,lastName=:lastName, email=:email, password=:password, user_type=:user_type";
// prepare query
$stmt = $this->conn->prepare($query);
// sanitize
$this->firstName=htmlspecialchars(strip_tags($this->firstName));
$this->lastName=htmlspecialchars(strip_tags($this->lastName));
$this->email=htmlspecialchars(strip_tags($this->email));
$this->password=htmlspecialchars(strip_tags($this->password));
$this->user_type=htmlspecialchars(strip_tags($this->user_type));
$this->password=md5($this->password);
// bind values
$stmt->bindParam(":firstName", $this->firstName);
$stmt->bindParam(":lastName", $this->lastName);
$stmt->bindParam(":email", $this->email);
$stmt->bindParam(":password", $this->password);
$stmt->bindParam(":user_type", $this->user_type);
// execute query
if($stmt->execute()){
return true;
header('location:profile.php');
}
return false;
}
}
if (isset($_REQUEST['register_btn'])) {
$user = new Users($conn);
$user->create();
}