Advertisement
Guest User

c_login

a guest
Feb 5th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class C_login extends CI_Controller {
  5.  
  6. function __Construct()
  7. {
  8. parent::__Construct();
  9. $this->load->model('m_login');
  10. $this->load->helper('url');
  11. }
  12.  
  13. function index()
  14. {
  15. $this->load->view('v_login');
  16. }
  17.  
  18. function proses_login()
  19. {
  20. $pengguna=$this->input->post('pengguna');
  21. $user=$this->input->post('username');
  22. $pass=$this->input->post('password');
  23.  
  24. $where=array(
  25. 'pengguna'=>$pengguna,
  26. 'username'=>$user,
  27. 'password'=>$pass
  28. );
  29. $cek=$this->m_login->cek_login ('login',$where)->num_rows();
  30.  
  31. if($cek>0)
  32. {
  33.  
  34. if($pengguna=='user')
  35. {
  36.  
  37.  
  38. $data_session=array(
  39. 'nama'=>$user,
  40. 'status'=>"login"
  41. );
  42.  
  43. $this->session->set_userdata($data_session);
  44.  
  45. redirect(base_url('index.php/admin'));
  46.  
  47. }
  48.  
  49. elseif ($pengguna=='super_user')
  50.  
  51. {
  52.  
  53. $data_session=array(
  54. 'nama'=>$user,
  55. 'status'=>"login"
  56. );
  57. $this->session->set_userdata($data_session);
  58.  
  59. redirect(base_url('index.php/admin_super_user'));
  60. }
  61.  
  62. }
  63. else
  64. {
  65. echo "<center>Anda belum menentukan Pengguna atau</center></br>";
  66. echo "<center>Username dan password salah</center></br>";
  67. echo anchor('','<center>Back</center>');
  68. }
  69.  
  70. }
  71.  
  72. function logout()
  73. {
  74. $this->session->sess_destroy();
  75. redirect(base_url('index.php'));
  76. //<?php echo base_url().'index.php/c_login/logout'?
  77. }
  78.  
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement