tripsdoc

Login.php

Dec 12th, 2016
630
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. <?php if (!defined('BASEPATH'))
  2. {
  3.     exit('No direct script access allowed');
  4. }  
  5.  
  6. class Login extends MY_Controller
  7. {
  8.     public function index()
  9.     {
  10.         if (!$_POST)
  11.         {
  12.             $input = (object) $this->login->getDefaultValues();
  13.         }
  14.         else
  15.         {
  16.             $input = (object) $this->input->post(null, true);
  17.         }
  18.        
  19.         if(!$this->login->validate())
  20.         {
  21.             $this->load->view('login_form', compact('input'));
  22.             return;
  23.         }
  24.        
  25.         if ($this->login->login($input))
  26.         {
  27.             redirect(base_url());
  28.         }
  29.         else
  30.         {
  31.             $this->session->set_flashdata('error', 'Username atau password salah, atau akun anda sedang diblokir.');
  32.         }
  33.        
  34.         redirect('login');
  35.     }
  36.     public function logout()
  37.     {
  38.         $this->login->logout();
  39.         redirect(base_url());
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment