2013-08-22 37 views
0

我有表單驗證這樣的:驗證假,雖然數據充滿

function insert() { 

    $this->form_validation->set_message('required', '*column must be filled'); 
    $this->form_validation->set_rules('judul', 'Judul', 'required'); 
    $this->form_validation->set_rules('isi', 'Isi', 'required'); 


    if ($this->form_validation->run() == FALSE) { 

     $this->layout->addJs('ckeditor/ckeditor.js'); 
     $this->layout->addJs('js/admin/b267648789c30a07b0efa5bce7bdd9fe.js'); 
     $this->layout->view('admin/admin_view/insertAdmin_view'); 
    } else { 

     $data = array(
      'title' => $this->input->post('judul'), 
      'content' => $this->input->post('isi'), 
    ); 
     $this->db->insert('newses', $data); 

     ... other proses ... 
       } 
    } 

雖然我填寫的數據表單中添加數據(我用的CKEditor添加數據),條件總是假的,所以它不會增加我想要的數據。但是如果我添加了一些html數據,卻出現了錯誤,但是如果我添加了正常的數據文本,它就很好用了。再一次當我在localhost xampp上運行我的程序時,這一切都有效,但是當我使用託管時發生。 有什麼建議嗎? 感謝您的所有建議。

+0

的錯誤,您是否獲得了CKEditor的值(在CKEditor的文字)的崗位價值? –

+0

但我認爲這不是問題,導致本地主機工作良好。在主機中是否有ckeditor的其他配置? – Cha

+0

請注意,代碼在localhost中運行,而不是在活動服務器上運行...檢查您是否在活動服務器上獲得ckeditor值。 –

回答

0

打印驗證

function insert() { 

$this->form_validation->set_message('required', '*column must be filled'); 
$this->form_validation->set_rules('judul', 'Judul', 'required'); 
$this->form_validation->set_rules('isi', 'Isi', 'required'); 
//echo validation_errors(); 
echo $this->input->post('judul')."<br>"; 
echo $this->input->post('isi'); 

if ($this->form_validation->run() == FALSE) { 

    $this->layout->addJs('ckeditor/ckeditor.js'); 
    $this->layout->addJs('js/admin/b267648789c30a07b0efa5bce7bdd9fe.js'); 
    $this->layout->view('admin/admin_view/insertAdmin_view'); 
} else { 

    $data = array(
     'title' => $this->input->post('judul'), 
     'content' => $this->input->post('isi'), 
); 
    $this->db->insert('newses', $data); 

    ... other proses ... 
      } 
    } 
+0

不工作,我得到'拒絕訪問網頁'。如果你把'退出'在'echo validation_error();'之後這意味着你停止編程,直到頁面無法載入,不是嗎? – Cha

+0

退出只意味着你想停止在這一點或檢查執行,直到這一點... –

+0

嘗試沒有退出......它將打印錯誤在頂部..我知道 –