Advertisement
vaganfree

auth

Dec 10th, 2016
674
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1. <?php
  2. class auth extends CI_Controller{
  3.    
  4.     function __construct() {
  5.         parent::__construct();
  6.         $this->load->model('model_operator');
  7.     }
  8.    
  9.     function login()
  10.     {
  11.         if(isset($_POST['submit'])){
  12.            
  13.             // proses login disini
  14.             $username   =   $this->input->post('username');
  15.             $password   =   $this->input->post('password');
  16.             $hasil=  $this->model_operator->login($username,$password);
  17.             if($hasil==1)
  18.             {
  19.                 // update last login
  20.                 $this->db->where('username',$username);
  21.                 $this->db->update('operator',array('last_login'=>date('Y-m-d')));
  22.                 $this->session->set_userdata(array('status_login'=>'oke','username'=>$username));
  23.                 redirect('dashboard');
  24.             }
  25.             else{
  26.                 redirect('auth/login');
  27.             }
  28.         }
  29.         else{
  30.             //$this->load->view('form_login2');
  31.             chek_session_login();
  32.             $this->load->view('form_login');
  33.         }
  34.     }
  35.    
  36.    
  37.     function logout()
  38.     {
  39.         $this->session->sess_destroy();
  40.         redirect('auth/login');
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement