Advertisement
GWibisono

perbaikan model

Apr 18th, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class Login_model extends CI_Model{
  4.  
  5.     public function __construct()
  6.     {
  7. //parent::__construct();
  8.              $this->load->session();
  9.              $this->load->database();
  10.             $this->load->dbforge();
  11.     }
  12.  
  13.     function validation_login(){
  14.         // filter      
  15.  
  16.         $username = $this->security->xss_clean( $this->input->post('username') );
  17.  
  18.         $password = $this->security->xss_clean( $this->input->post('password') );
  19.  
  20.         // seleksi data dari username dan password dan status aktif
  21.  
  22.         $this->db->where('user_name', $username);
  23.  
  24.         $this->db->where('user_password', $password);
  25.  
  26.         $this->db->where('status', '1');
  27.  
  28.         $rs = $this->db->get('view_user_login');
  29.  
  30.         // get result row, prepare and create session
  31.  
  32.         if ( 1 == $rs->num_rows ) {
  33.  
  34.             $data = $rs->row();
  35.  
  36.             $vars = array(
  37.  
  38.                 "no"        => $data->no,
  39.  
  40.                 "id_role"   => $data->id_role, // pkey to role
  41.  
  42.                 "role_name" => $data->role_name,
  43.  
  44.                 "user_name" => $data->user_name,
  45.  
  46.                 "no_emp"    => $data->no_emp, // unique to employee
  47.  
  48.                 "name"      => $data->name,
  49.  
  50.                 "validated" => true
  51.  
  52.                 );      
  53.  
  54.             $this->session->set_userdata( $vars );
  55.  
  56.             return true;
  57.  
  58.         }
  59.         else {
  60.  
  61.             return false;
  62.  
  63.         }
  64.  
  65.     }
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement