2016-04-20 19 views
-1

こんにちは私は何を私のコードで間違っているのか把握しようとしている、フォームの検証は常にfalseを返します。 は、ここに私のコントローラからのコードスニペットです:なぜ私のForm_validationは常にFALSEを返しますか?

function edit() 
{ 
    //load form_validation class 
    $this->load->library('form_validation'); 

    //set validation rules 
    $this->form_validation->set_rules('username','Username','required|trim|xss_clean'); 
    $this->form_validation->set_rules('password_old','password lama','required|trim|xss_clean'); 
    $this->form_validation->set_rules('password_new1','password baru','required|trim|xss_clean'); 
    $this->form_validation->set_rules('password_new2','confirm password','required|trim|xss_clean|matches[password_new1]'); 

    if ($this->form_validation->run() == FALSE) 
    { 
     $this->session->set_flashdata('flash_data', 'Lengkapi Form Dengan Benar dan Lengkap'); 
     redirect('admin/akun'); 
    } 
    else 
    { 
     $this->load->model("user_model","user"); 
     if($_POST) 
     { 
      $result = $this->user->edit_user($_POST); 
      if($result == FALSE) 
      { 
       $data['page'] = $this->config->item('ci_my_admin_template_dir_admin') . "error_message"; 
       $this->load->view($this->_container, $data); 
      } 
      else 
      { 
       $this->session->set_flashdata('flash_data', 'Silahkan Log In dengan Username dan Password yang baru!'); 
       redirect('admin/logout'); 
      } 
     } 
    } 
}     

私はそれが動作するために変更する必要があり、他の構成があるの?私の検証ルール内

+1

私は最初は 'else'エコーvalidation_errors('追加した後、適切に – Kunal

+0

フィールドのfalse.So、クロスチェックの名前を返す理由です、ビュー内および検証ルールの入力フィールドの名前が一致しないと思います) ; exit(); 'をチェックしてください。 –

+0

ビューを追加してください。 –

答えて

0

をxss_cleanを加えながら、私はあなたがCodeIgniterのを使用する必要がヘルパー(「セキュリティ」)をロードしませんでした SOLVED->私の悪い:

EDIT ..助けてくれてありがとうInputクラス。

function edit() 
    { 
     //load form_validation class 
     $this->load->library('form_validation'); 

     //set validation rules 
     $this->form_validation->set_rules('username','Username','required|trim|xss_clean'); 
     $this->form_validation->set_rules('password_old','password lama','required|trim|xss_clean'); 
     $this->form_validation->set_rules('password_new1','password baru','required|trim|xss_clean'); 
     $this->form_validation->set_rules('password_new2','confirm password','required|trim|xss_clean|matches[password_new1]'); 

     if ($this->form_validation->run() == FALSE) 
     { 
      $this->session->set_flashdata('flash_data', 'Lengkapi Form Dengan Benar dan Lengkap'); 
      redirect('admin/akun'); 
     } 
     else 
     { 
      $data['password_old'] = $this->input->post('password_old'); 
      $data['password_new1'] = $this->input->post('password_new1'); 
      $data['password_new1'] = $this->input->post('password_new1'); 

      $this->load->model("user_model","user"); 

       $result = $this->user->edit_user($data); 
       if($result == FALSE) 
       { 
        $this->session->set_flashdata('flash_data', 'Silahkan Log In dengan Username dan Password yang baru!'); 
        redirect('admin/logout'); 
       } 
       else 
       { 
        $data['page'] = $this->config->item('ci_my_admin_template_dir_admin') . "error_message"; 
        $this->load->view($this->_container, $data); 

       } 

     } 
    } 
} 
+0

あなたのellislabのリンクの日付が間違っていて、もうcodeIgniterを扱わない場合は、http://www.codeigniter.com/docsから現在の古い文書を入手できます。これらの文書のリンクを試してみてください。 – user4419336

+0

ありがとう@ wolfgang1983 – cgds

関連する問題