Advertisement
Guest User

Controller Login

a guest
Jun 29th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. class Login extends CI_Controller
  5. {
  6.  
  7. public function __construct()
  8. {
  9. parent::__construct();
  10. $this->load->model('ModelLogin','m_login',true);
  11. $this->load->library('session');
  12. //die(md5('user'));
  13. }
  14.  
  15. public function index(){
  16. echo '<h2>Ini Halaman Login</h2>';
  17. $this->load->view('PageLogin');
  18. }
  19.  
  20. public function proses(){
  21. $username = $this->input->post('username');
  22. $password = $this->input->post('password');
  23.  
  24. $cek_user = $this->m_login->cek_user_login($username,md5($password));
  25.  
  26. if($cek_user->num_rows() > 0){
  27.  
  28. $set_session = $cek_user->row_array();
  29. $this->session->set_userdata($set_session);
  30. redirect(base_url('halaman/buku'));
  31. }else{
  32. echo 'password atau user yang anda masukkan salah';
  33. die();
  34. }
  35.  
  36. }
  37.  
  38. public function logout(){
  39. $this->session->sess_destroy();
  40. redirect(base_url('login'));
  41. }
  42. }
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement