Advertisement
brunolc

erroCodeIgniter

Nov 10th, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.17 KB | None | 0 0
  1. <script>
  2.     $("#logar").click(function(event) {
  3.       event.preventDefault();
  4.       var email = $('#emailL').val();
  5.       var senha = $('#passwordL').val();
  6.       var url = "<?= base_url("login/autenticar"); ?>";
  7.       $.post(url,{
  8.         email : email,
  9.         async: true,
  10.         password : senha
  11.       }, function(event){
  12.         if(event === "1"){
  13.           $('#erroEmail').html("<img src='<?= base_url('img/l568ECv.gif')?>'' alt='' id='imgLoad'>");
  14.           $('#imgLoad').show();
  15.           setTimeout(function(){
  16.            window.location ="<?= base_url('edit') ?>";
  17.          }, 3000);
  18.  
  19.         }else{
  20.           $('#erroEmail').html(event);
  21.         }
  22.       });
  23.     });
  24.  
  25.   </script>
  26.  
  27.  
  28.  
  29. public function autenticar() {
  30.         $this->load->model("cadastro_model");
  31.         $email = $this->input->post("email");
  32.         $senha = md5($this->input->post("password"));
  33.         $usuario = $this->cadastro_model->buscaPorEmailESenha($email, $senha);
  34.         if($usuario) {
  35.             $this->session->set_userdata("logado" , $usuario);
  36.             echo "1";
  37.             die();
  38.         } else {
  39.             echo "<i class='material-icons alinhaIcone margenIcone'>thumb_down</i>Login or password invalid.";
  40.             die();
  41.         }
  42.        
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement