Advertisement
Guest User

model login

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