emprit

login_model

Sep 13th, 2012
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.91 KB | None | 0 0
  1. <?php if (! defined('BASEPATH')) exit ('NO direct script access allowed');
  2.  
  3.     class Login_model extends CI_Model{
  4.    
  5.         public function login($user_id){
  6.             $CI = & get_instance();
  7.             $CI->session->set_userdata('logged', $userdata);
  8.         }
  9.        
  10.         public function logout(){
  11.             $CI = & get_instance();
  12.             $CI->session->sess_destroy();
  13.         }
  14.        
  15.         public function validate($nama, $password){
  16.             $query = $this->db->get_where('login', array('nama' => $nama));
  17.             $cek   = $query->num_rows();
  18.             if($cek != 0){
  19.                 foreach($query->result() as $row):
  20.                 $client['id_client'] = $row->id_user;
  21.                 $client['nama']       = $row->nama;
  22.                 $client['password']  = $row->password;
  23.                 endforeach;
  24.                
  25.                 $passmd5 = md5($password);
  26.                
  27.                 if($passmd5 == $client['password']){
  28.                     $this->login($client['id_client']);
  29.                     return true;
  30.                     }else{
  31.                     return false;
  32.                     }
  33.             }else{
  34.                 return false;
  35.                 }
  36.         }
  37.    
  38.     }
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment