Advertisement
Guest User

Untitled

a guest
May 12th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1.         public function login()
  2.         {
  3.             $this->input = Kohana::instance()->input;
  4.             $username = $this->input->post('username');
  5.             $password = $this->input->post('password');
  6.  
  7.  
  8.             $user = ORM::factory('user', $username);
  9.             $this->auth = new Auth();
  10.  
  11.             $user->username = $username;
  12.             $user->password = $password;
  13.  
  14.             if (!$user->loaded()) // if user is not found
  15.             {
  16.                 echo "USERNAME not valid";
  17.             } else if ($this->auth->login($username, $password)) { // if login() is returns TRUE
  18.                 echo "Hello, " . $this->auth->get_user()->username;// greet the user
  19.             } else {
  20.                 echo "Login failed!";
  21.             }
  22.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement