Advertisement
Guest User

Untitled

a guest
Jun 11th, 2017
537
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.20 KB | None | 0 0
  1. //controleer
  2.  
  3. <?php
  4. /**
  5.  * Login Class
  6.  *
  7.  * @author  Awan Pribadi Basuki <awan_pribadi@yahoo.com>
  8.  */
  9. class Login extends Controller {
  10.     /**
  11.      * Constructor
  12.      */
  13.     function login()
  14.     {
  15.         parent::Controller();
  16.         $this->load->model('Login_model', '', TRUE);
  17.     }
  18.    
  19.     /**
  20.      * Memeriksa user state, jika dalam keadaan login akan menampilkan halaman absen,
  21.      * jika tidak akan meload halaman login
  22.      */
  23.     function index()
  24.     {
  25.         if ($this->session->userdata('login') == TRUE)
  26.         {
  27.             redirect('absen');
  28.         }
  29.         else
  30.         {
  31.             $this->load->view('login/login_view');
  32.         }
  33.     }
  34.    
  35.     /**
  36.      * Memproses login
  37.      */
  38.     function process_login()
  39.     {
  40.         $this->form_validation->set_rules('username', 'Username', 'required');
  41.         $this->form_validation->set_rules('password', 'Password', 'required');
  42.        
  43.         if ($this->form_validation->run() == TRUE)
  44.         {
  45.             $username = $this->input->post('username');
  46.             $password = $this->input->post('password');
  47.            
  48.             if ($this->Login_model->check_user($username, $password) == TRUE)
  49.             {
  50.                 $data = array('username' => $username, 'login' => TRUE);
  51.                 $this->session->set_userdata($data);
  52.                 redirect('absen');
  53.             }
  54.             else
  55.             {
  56.                 $this->session->set_flashdata('message', 'Maaf, username dan atau password Anda salah');
  57.                 redirect('login/index');
  58.             }
  59.         }
  60.         else
  61.         {
  62.             $this->load->view('login/login_view');
  63.         }
  64.     }
  65.    
  66.     /**
  67.      * Memproses logout
  68.      */
  69.     function process_logout()
  70.     {
  71.         $this->session->sess_destroy();
  72.         redirect('login', 'refresh');
  73.     }
  74. }
  75. // END Login Class
  76.  
  77. /* End of file login.php */
  78. /* Location: ./system/application/controllers/login.php */
  79.  
  80.  
  81.  
  82.  
  83. //view
  84.  
  85. <?php
  86. /**
  87.  * Login Class
  88.  *
  89.  * @author  Awan Pribadi Basuki <awan_pribadi@yahoo.com>
  90.  */
  91. class Login extends Controller {
  92.     /**
  93.      * Constructor
  94.      */
  95.     function login()
  96.     {
  97.         parent::Controller();
  98.         $this->load->model('Login_model', '', TRUE);
  99.     }
  100.    
  101.     /**
  102.      * Memeriksa user state, jika dalam keadaan login akan menampilkan halaman absen,
  103.      * jika tidak akan meload halaman login
  104.      */
  105.     function index()
  106.     {
  107.         if ($this->session->userdata('login') == TRUE)
  108.         {
  109.             redirect('absen');
  110.         }
  111.         else
  112.         {
  113.             $this->load->view('login/login_view');
  114.         }
  115.     }
  116.    
  117.     /**
  118.      * Memproses login
  119.      */
  120.     function process_login()
  121.     {
  122.         $this->form_validation->set_rules('username', 'Username', 'required');
  123.         $this->form_validation->set_rules('password', 'Password', 'required');
  124.        
  125.         if ($this->form_validation->run() == TRUE)
  126.         {
  127.             $username = $this->input->post('username');
  128.             $password = $this->input->post('password');
  129.            
  130.             if ($this->Login_model->check_user($username, $password) == TRUE)
  131.             {
  132.                 $data = array('username' => $username, 'login' => TRUE);
  133.                 $this->session->set_userdata($data);
  134.                 redirect('absen');
  135.             }
  136.             else
  137.             {
  138.                 $this->session->set_flashdata('message', 'Maaf, username dan atau password Anda salah');
  139.                 redirect('login/index');
  140.             }
  141.         }
  142.         else
  143.         {
  144.             $this->load->view('login/login_view');
  145.         }
  146.     }
  147.    
  148.     /**
  149.      * Memproses logout
  150.      */
  151.     function process_logout()
  152.     {
  153.         $this->session->sess_destroy();
  154.         redirect('login', 'refresh');
  155.     }
  156. }
  157. // END Login Class
  158.  
  159. /* End of file login.php */
  160. /* Location: ./system/application/controllers/login.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement