Advertisement
jeniapriansya1

Untitled

Aug 19th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Site extends MX_Controller {
  5.  
  6. public function __construct(){
  7. parent::__construct();
  8. }
  9.  
  10. public function index(){
  11. $this->page->template('login_tpl');
  12. $this->page->view();
  13. }
  14.  
  15. public function login(){
  16. $username = $this->input->post('username');
  17. $pass = $this->input->post('password');
  18. $password = MD5($pass);
  19.  
  20. $src = $this->db->get_where('pengguna', array (
  21. 'username' => $username,
  22. 'password' => $password,
  23. ));
  24.  
  25. if ($src->num_rows() == 0) {
  26. $this->session->set_flashdata('status', 'failed');
  27. redirect(base_url());
  28. }
  29. else {
  30. $pengguna = $src->row();
  31. $this->session->set_userdata('pengguna', $pengguna);
  32.  
  33. redirect(site_url('/dashboard'));
  34. }
  35. }
  36.  
  37. public function logout(){
  38. $this->session->sess_destroy();
  39. redirect(base_url());
  40. }
  41.  
  42. }
  43.  
  44. /* End of file site.php */
  45. /* Location: ./application/controllers/site.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement