<?php
class Login_model {
    private $db;

    public function __construct() {
        $this->db = new Database;
    }

    public function register($data){
        $username = $data['username'];
        $email = $data['email'];
        $password = md5($data['password']);

        $sql = "INSERT INTO tbl_login (username, email, password)
                VALUES ('$username', '$email', '$password');";

        return $this->db->query($sql);
    }

    public function login($email, $password){
        $password = md5($password);

        $sql = "SELECT * FROM tbl_login 
                WHERE email='$email' AND password='$password'";

        $result = $this->db->query($sql);
        return $result->fetch_assoc();
    }
}
?>
