Please,am learning how to code a simple PDO login system. One of my files, that is User.php has an error after rendering.
This is my code:
<?php
include_once('connection.php');
class User{
private $db;
public function _construct(){
$this->db = new Connection();
$this->db = $this->db->dbConnect();
}
public function login($name,$pass){
if(!empty($name) && !empty($pass)){
$stmt = $this->db->prepare(" SELECT * FROM users WHERE name = ? and pass = ? ");
$stmt -> bindParam(1,$name);
$stmt -> bindParam(2,$pass);
$stmt -> execute();
if($stmt->rowCount()==1){
echo "successfully login";
}else{
echo "incorrect username or password";
}
} else{
echo "enter correct username and password";
}
Here is the error:
Fatal error: Call to a member function prepare() on null in C:\xampp\htdocs\simplelogin\User.php on line 16