Guest User

Untitled

a guest
Jan 20th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. $this->load->library('form_validation');
  2. $this->form_validation->set_rules('username','Username','required');
  3. $this->form_validation->set_rules('password','Password','required');
  4.  
  5. if($this->form_validation->run()){
  6. //variables
  7. $username = $this->input->post('username');
  8. $password = md5($this->input->post('password'));
  9. //model function
  10. $this->load->model('main_model');
  11. if($this->main_model->can_login($username,$password)){
  12. $session_data = array(
  13. `username` => $username
  14. );
  15. $this->session->set_userdata($session_data);
  16. redirect(base_url() . 'home/admin');
  17. }
  18. else{
  19. $this->session->set_flashdata('error','Invalid Username and Password');
  20. redirect(base_url() . 'home/index');
  21. }
  22. }
  23. else{
  24. $this->index();
  25. }
Add Comment
Please, Sign In to add comment