Advertisement
Guest User

Untitled

a guest
Mar 30th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.70 KB | None | 0 0
  1. <?php
  2.  class Login extends CI_Controller {
  3.     public function _construct()
  4.     {
  5.         parent::_construct();
  6.         $this->load->model('MUser');
  7.      }
  8.  
  9.          public function index()
  10.          {
  11.           if ($this->session->userdata('logged') == true ) {
  12.             redirect('rental') ;          
  13.           }else{
  14.             $this->load->view('login');
  15.           }
  16.          }
  17.  
  18.              public function validasi()
  19.               {
  20.                 $this->load->library('form_validation');
  21.                 $this->form_validation->set_rules('username', 'Username', 'required');
  22.                 $this->form_validation->set_rules('password', 'Password', 'required');
  23.                    
  24.                     if($this->form_validation->run() == true) {
  25.                       $username = $this->input->post('username');
  26.                        $password = $this->input->post('password');
  27.  
  28.                         if($this->MUser->CheckUser($username,$password) == true) {
  29.                           $data = array('username'=>$username, 'logged'=>true);
  30.                           $this->session->set_userdata($data);
  31.                             redirect('rental');
  32.  
  33.                         }else{
  34.                           $this->session->set_flashdata('pesan', 'Username atau password anda salah');
  35.  
  36.                              redirect('Login');
  37.                        }
  38.  
  39.                     } else {
  40.                       $this->load->view('login');
  41.                     }    
  42.               }
  43.  
  44.               public function logout()
  45.               {
  46.                 $this->session->session_destroy();
  47.                 redirect('Login', 'referesh');
  48.               }
  49.             }
  50.   ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement