Advertisement
handc0de

Untitled

Nov 1st, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. <?php
  2.  
  3. class Login extends ci_controller{
  4.  
  5.  
  6. public function index(){
  7. $this->load->view('view_login');
  8. }
  9.  
  10. public function proses_login(){
  11. if(isset($_POST['login'])){
  12. $nama_login = $this->input->post('nama_login');
  13. $password_login = $this->input->post('password_login');
  14. $sql = "SELECT * FROM guru where username = '$nama_login' and pass = '$password_login'";
  15. $rs=$this->db->query($sql);
  16.  
  17. if($rs->num_rows() > 0){
  18. $myuser = $rs->row();
  19. $this->session->set_userdata('username',$myuser->username);
  20.  
  21. redirect('from_walikelas','refresh');
  22.  
  23.  
  24. }else{
  25. ?>
  26. <script type="text/javascript">
  27. alert("Gagal Login !!!");window.location='<?php base_url(); ?>login';
  28. </script>
  29. <?php
  30.  
  31.  
  32. }
  33. }
  34. }
  35.  
  36. public function redirect(){
  37. $this->load->view('v_redirect');
  38. }
  39. public function redirect_logout(){
  40. $this->load->view('v_redirect_logout');
  41. }
  42.  
  43. public function logout(){
  44. $this->session->sess_destroy();
  45. redirect('login','refresh');
  46. }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement