Guest User

Untitled

a guest
May 25th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. <?
  2. class Login extends Controller {
  3.  
  4. function Login()
  5. {
  6. parent::Controller();
  7. $this->load->helper('url');
  8. $this->load->library('session');
  9. }
  10.  
  11. function index()
  12. {
  13. $data['base'] = $this->config->item('base_url');
  14. $data['css'] = $this->config->item('css');
  15.  
  16. $this->load->helper(array('form', 'url')); // load form
  17. $this->load->library('validation'); // load validations
  18. $rules['username'] = 'trim|required|xss_clean|callback__check_logindata';
  19. $rules['password'] = 'trim|required|md5';
  20.  
  21.  
  22.  
  23. $fields['username']='Username';
  24. $fields['password']= 'Password ';
  25.  
  26.  
  27. $this->validation->set_fields($fields);
  28. $this->validation->set_rules($rules);
  29.  
  30.  
  31. if ($this->validation->run() == TRUE)
  32. {
  33. $this->load->model('Mlogin','',TRUE);
  34. $password = $this->validation->password;
  35. $username = $this->validation->username;
  36. if ($this->Mlogin->check_login_data($username, $password) == FALSE)
  37. {
  38. $this->validation->set_message('_check_logindata', 'Usu&aacute;rio ou senha inv&aacute;lidos!');
  39. return FALSE;
  40. }
  41. }
  42. else
  43. {
  44. $this->load->view('login_view' , $data);
  45. }
  46. }
  47.  
  48.  
  49. function _check_logindata($username) {
  50.  
  51. $username = $this->input->post('username');
  52. $password = $this->input->post('password');
  53.  
  54. $this->load->model('Mlogin');
  55. if ($this->Mlogin->check_login_data($username, $password) == FALSE)
  56. {
  57. $this->validation->set_message('_check_logindata', 'Usu&aacute;rio ou senha inv&aacute;lidos!');
  58. return FALSE;
  59. }
  60. else
  61. {
  62. $this->session('user') = $username;
  63. redirect('zimba/');
  64. return TRUE;
  65. }
  66. }
  67.  
  68. }
  69. ?>
Add Comment
Please, Sign In to add comment