Advertisement
jamboljack

Validasi

Jan 5th, 2015
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.66 KB | None | 0 0
  1. public function validasi() {
  2.         $username = $this->input->post('username', 'true');
  3.         $password = $this->input->post('password', 'true');        
  4.        
  5.         $this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[5]|max_length[20]|xss_clean');
  6.         $this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[5]|max_length[15]|xss_clean');
  7.        
  8.         $temp_user = $this->session_model->get_user($username)->row();
  9.         $num_user = count($temp_user);                     
  10.        
  11.         if ($this->form_validation->run() == FALSE) {
  12.             $this->load->view('login_v');
  13.         } else {
  14.             if ($num_user == 0) { // Username Tidak Terdaftar
  15.                 $this->session->set_flashdata('notification','Username Anda tidak Terdaftar, Hubungi Administrator !');
  16.                 redirect(site_url('session/login'));
  17.             } elseif ($num_user > 0) { // Username Terdaftar               
  18.                 $temp_account = $this->session_model->check_user_account($username, sha1($password))->row();
  19.                 $num_account = count($temp_account);
  20.        
  21.                 if ($num_account > 0) {
  22.                     $array_item = array('a_user_id' => $temp_account->user_id,
  23.                                         'a_username' => $temp_account->user_username,
  24.                                         'a_nama_lengkap' => $temp_account->user_name,
  25.                                         'a_level' => $temp_account->user_level,
  26.                                         'a_avatar' => $temp_account->user_avatar,                                      
  27.                                         'logged_in_teknik' => TRUE);
  28.                                                                            
  29.                     $this->session->set_userdata($array_item);
  30.                     redirect(site_url('panel/home'));                                                  
  31.                 } else {                   
  32.                     $this->session->set_flashdata('notification','LOGIN GAGAL !!, Username and Password Anda Tidak Cocok.');
  33.                     redirect(site_url('session/login'));                   
  34.                 }              
  35.             }                              
  36.         }      
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement