Advertisement
Guest User

Untitled

a guest
Nov 16th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1.     public function userLogin($data)
  2.     {
  3.         $username = mysqli_real_escape_string($this->db->link, $data['username']);
  4.         $password = mysqli_real_escape_string($this->db->link, $data['password']);
  5.  
  6.         if (empty($username) or empty($password)) {
  7.             $msg = "Fields must not be empty!";
  8.             return $msg;
  9.         }
  10.  
  11.         $query = "SELECT * FROM tbl_users WHERE username='$username'";
  12.         $result = $this->db->select($query);
  13.         if ($result != false) {
  14.             $value = $result->fetch_assoc();
  15.             if ($this->passwordVerify($password, $value['password'])) {
  16.                 Session::set('userlogin', true);
  17.                 Session::set('userId', $value['id']);
  18.                 Session::set('userName', $value['username']);
  19.                 header('Location: index.php');
  20.             } else {
  21.                 $msg = "Username or password not matched!";
  22.                 return $msg;
  23.             }
  24.         }
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement