Advertisement
Guest User

Controller

a guest
Jan 18th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class C_log extends CI_Controller {
  5.  
  6. function __construct(){
  7. parent::__construct();
  8.  
  9. $this->load->model('Panel_model');
  10. $this->load->library('form_validation');
  11.  
  12. }
  13.  
  14. function auth(){
  15. if ($_POST)
  16. {
  17. $this->form_validation->set_rules('username','Username'.'required|trim|xss_clean');
  18. $this->form_validation->set_rules('password','Password'.'required|trim|xss_clean');
  19.  
  20. if($this->form_validation->run() == TRUE )
  21. {
  22. redirect('backend/home');
  23. }
  24.  
  25. $username = $this->input->post('username');
  26. $password = md5($this->input->post('password'));
  27.  
  28. $auth = $this->Panel_model->login_panel("where username = '$username' and password = '$password'")->result_array();
  29.  
  30. if ($auth != NULL){
  31. $data = array(
  32. 'username' => $auth[0]['username'],
  33. 'email' => $auth[0]['email'],
  34. 'fullname' => $auth[0]['fullname'],
  35. 'level_user'=> $auth[0]['level_user']
  36. );
  37.  
  38. $this->session->set_userdata('login',$data);
  39. redirect('backend/home');
  40. }
  41. else {
  42. $this->load->view('backend/error');
  43. }
  44.  
  45.  
  46.  
  47.  
  48. }
  49. }
  50. }
  51.  
  52. /* End of file C_log.php */
  53. /* Location: ./application/controllers/C_log.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement