Guest User

Untitled

a guest
Jan 30th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Auth extends CI_Controller {
  5.  
  6. public function __construct()
  7. {
  8. parent::__construct();
  9.  
  10. $this->load->model('Auth_model');
  11. $this->load->library('form_validation');
  12. }
  13.  
  14. public function index()
  15. {
  16.  
  17. $this->load->view('auth_view');
  18. }
  19. public function aksi_login(){
  20. $username = $this->input->post('username');
  21. $password = $this->input->post('password');
  22. $where = array(
  23. 'username' => $username,
  24. 'password' => md5($password)
  25. );
  26. $cek = $this->Auth_model->cek_login("users",$where)->num_rows();
  27. if($cek > 0){
  28.  
  29. $data_session = array(
  30. 'nama' => $username,
  31. 'status' => "login"
  32. );
  33.  
  34. $this->session->set_userdata($data_session);
  35.  
  36. redirect(base_url("home"));
  37.  
  38. }else{
  39. echo "Username dan password salah !";
  40. }
  41. }
  42.  
  43. function logout(){
  44. $this->session->sess_destroy();
  45. redirect(base_url('auth'));
  46. }
  47.  
  48. }
Add Comment
Please, Sign In to add comment