Advertisement
arifvoyager

controller login

Nov 8th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. <?php
  2. class home extends CI_Controller{
  3. function __construct(){
  4. parent::__construct();
  5. $this->load->model('pengguna_model');
  6.  
  7. }
  8.  
  9. // function index(){
  10. // $this->load->view('home/login.php');
  11. // }
  12.  
  13. function aksi_login(){
  14. $username = $this->input->post('pengguna');
  15. $password = $this->input->post('password');
  16. $where = array(
  17. 'pengguna' => $username,
  18. 'password' => md5($password)
  19. );
  20. $cek = $this->pengguna_model->cek_login("pengguna",$where)->num_rows();
  21. if($cek > 0){
  22.  
  23. $data_session = array(
  24. 'pengguna' => $username,
  25. 'password' => md5($password)
  26. );
  27.  
  28. $this->session->set_userdata($data_session);
  29.  
  30. redirect('dashboard');
  31.  
  32. }else{
  33. echo "Username dan password salah !";
  34. }
  35. }
  36.  
  37. function logout(){
  38. $this->session->sess_destroy();
  39. rredirect('depan/login');
  40. }
  41.  
  42. }
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement