2014-02-18 4 views
0

로그인 폼 유효성 검사가 작동하지 않습니다. 가입시 잘 작동하지만 로그인 양식과 동일한 시도를했을 때 코드 점화기에서 제대로 작동하지 않는 검사가 있습니다. 여기 내 코드입니다. 코드를 실행하면 다른 조건이되지만 유효성 검사 오류가 표시되지 않습니다. 나를 위해 문제를 만드는 처음 두 검사. 입력이 비어 있거나 잘못된 형식의 전자 메일을 입력 할 때.codeigniter의 로그인 폼 유효성 검사가 작동하지 않습니다.

function index() { 
    $data['nav']= $this->category_model->view_brands(); 

    if($_POST) { 
     $data['error'] = ''; 
     $this->load->library('form_validation'); 
     $this->form_validation->set_rules('email_login', 'Email', 'required|valid_email'); 
     $this->form_validation->set_rules('password_login', 'Password', 'required'); 

     if($this->form_validation->run() !== FALSE) { 
      $log_in = $this->login_model->login_beyond(
         $this->input->post('email_login'), 
         md5($_POST['password_login']) 
        ); 

      if($log_in !== FALSE) { 
       echo "<script>window.location.href=\"../index.php\"</script>"; 
      } 
      else { 
       // Set your error message 
       $data['error'] = 'Wrong Username/Password'; 
      } 
     } 
     else { 
      // Set the validation errors 
      echo "it came heere but donot show errors"; 
      $data['error'] =validation_errors(); 
     } 
    } 

    $data['login_not'] = "login"; 
    $this->template->load('template','client/login_view',$data); 
} 
+0

는 아무것도 표시되지 않습니다 ...하지만 내가하지 it..But 오류 위의 에코 다른 condition.As에 온다 또한 어떤 오류 –

+0

를보기 코드를 추가 작동하는 경우

맞쳐 알고 come.It 동일한 양식을 보여줍니다. –

+0

를 표시 – user1542996

답변

0

그것은 if ($this->form_validation->run() === FALSE)를 작성하고 거기에서 대신 if($this->form_validation->run() !== FALSE)를 작성하는 일을하는 것이 가장 좋습니다. 이것은 양식 유효성 검사에서 run()이 true를 반환 할 때 모든 결과를 평가했기 때문일 수 있으며 오류를 발견하지 못했거나 주어진 값이 존재하지 않아 존재하지 않는 값에 오류 검증이 적용되지 않았기 때문일 수 있습니다. 이

관련 문제