0
這裏是控制器內我的登錄方法,我在這裏設置的驗證錯誤提示信息 -驗證flashdata誤差不笨顯示
public function login(){
$this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[3]');
$this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[3]');
if($this->form_validation->run() == FALSE){
$data = array(
'errors' => validation_errors()
);
$this->session->set_flashdata($data);
redirect('home');
}
}
這裏的ID代碼以顯示這些錯誤 -
<?php if($this->session->flashdata('errors')): ?>
<?php echo $this->session->flashdata('errors');?>
<?php endif; ?>
我不知道什麼是錯,錯誤信息不顯示。
嘗試像這樣$ this-> session-> set_flashdata('errors',validation_errors());作爲單個項目而不是數組。 –
再次檢查文檔。您必須加載視圖,而不是在表單失敗的情況下重定向。設置會話後,在其他塊中進行重定向。 – Tpojka