Advertisement
Guest User

Controlador login

a guest
Nov 23rd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. /**
  4. * @author ralf
  5. * @desc Clase Login que contiene autenticación de usuarios
  6. * **/
  7. class Login extends CI_Controller{
  8.  
  9. public function __construct(){
  10. parent::__construct();
  11. $this->load->model(array(
  12. 'ion_auth_model'
  13. ));
  14. $this->load->library(
  15. array(
  16. 'ion_auth'
  17. ));
  18. $this->load->helper(array('url','language'));
  19. //$this->form_validation->set_error_delimiters($this->config->item('error_start_delimiter', 'ion_auth'), $this->config->item('error_end_delimiter', 'ion_auth'));
  20. $this->lang->load('auth');
  21. }
  22.  
  23. public function index(){
  24.  
  25. $this->load->helper(array('form', 'url'));
  26. $this->load->library('form_validation');
  27. //
  28. $this->form_validation->set_error_delimiters('<div class="alert alert-danger">', '</div>');
  29. $this->form_validation->set_rules('inputEmail', 'E-Mail', 'required|trim|valid_email');
  30. $this->form_validation->set_rules('inputPassword', 'Password', 'required|trim');
  31. //
  32. if ($this->form_validation->run() == FALSE){
  33. $this->load->view("header/login");
  34. $this->load->view("templates/login");
  35. $this->load->view("footer/footer_login");
  36. }else{
  37. //TRUE del formulario
  38. $this->input->post('peso');
  39. $this->input->post('peso');
  40. $remember = TRUE;
  41. if($this->ion_auth->login($this->input->post('inputEmail'), $this->input->post('inputPassword'),$remember)){
  42. redirect('imc/index', 'refresh');
  43. }else{
  44. $datos['message'] = "Error, usuario o contrase&ntilde;a incorrecta";
  45. $this->load->view("header/login");
  46. $this->load->view("templates/login", $datos);
  47. $this->load->view("footer/footer_login");
  48. }
  49.  
  50. }
  51.  
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement