Advertisement
Guest User

Untitled

a guest
Feb 1st, 2017
15,861
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.81 KB | None | 0 0
  1. <?php
  2.  
  3. class Login extends CI_Controller{
  4.  
  5.     function __construct(){
  6.         parent::__construct();     
  7.         $this->load->model('m_login');
  8.  
  9.     }
  10.  
  11.     function index(){
  12.         $this->load->view('v_login');
  13.     }
  14.  
  15.     function aksi_login(){
  16.         $username = $this->input->post('username');
  17.         $password = $this->input->post('password');
  18.         $where = array(
  19.             'username' => $username,
  20.             'password' => md5($password)
  21.             );
  22.         $cek = $this->m_login->cek_login("admin",$where)->num_rows();
  23.         if($cek > 0){
  24.  
  25.             $data_session = array(
  26.                 'nama' => $username,
  27.                 'status' => "login"
  28.                 );
  29.  
  30.             $this->session->set_userdata($data_session);
  31.  
  32.             redirect(base_url("index.php/admin"));
  33.  
  34.         }else{
  35.             echo "Username dan password salah !";
  36.         }
  37.     }
  38.  
  39.     function logout(){
  40.         $this->session->sess_destroy();
  41.         redirect(base_url('login'));
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement