Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- public function login(){
- // If method was not POST goes to the login form
- if($_SERVER['REQUEST_METHOD'] == 'GET'){
- require_once('views/users/login.php');
- }
- else {
- // this try and catch does not work
- try{
- // if username and password matched, it will return user_id
- $user_id = User::login();
- $user = User::find($user_id);
- $_SESSION['user_id']=$user->id;
- $_SESSION['username']=$user->username;
- $_SESSION['admin_level']=$user->admin_level;
- return call('user', 'show');
- }
- catch (Exception $ex){
- return call('pages','error');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement