Advertisement
Guest User

Untitled

a guest
May 26th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. <?php
  2.  
  3. public function login(){
  4.  
  5.         // If method was not POST goes to the login form
  6.         if($_SERVER['REQUEST_METHOD'] == 'GET'){
  7.               require_once('views/users/login.php');
  8.             }
  9.         else {  
  10.             // this try and catch does not work
  11.             try{
  12.                 // if  username and password matched, it will return user_id
  13.                 $user_id = User::login();
  14.                 $user = User::find($user_id);
  15.                
  16.                 $_SESSION['user_id']=$user->id;
  17.                 $_SESSION['username']=$user->username;
  18.                 $_SESSION['admin_level']=$user->admin_level;
  19.                
  20.                 return call('user', 'show');
  21.             }
  22.             catch (Exception $ex){
  23.                 return call('pages','error');
  24.             }
  25.         }          
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement