0
$this->form_validation->set_rules('username', 'User Name', 'required|min_length[4]|is_unique[users.username]');
$this->form_validation->set_rules('fname', 'Full Name', 'required|min_length[4]');
$this->form_validation->set_rules('user_password', 'Password', 'required|matches[confirm_password]');
$this->form_validation->set_rules('confirm_password', 'Confirm Password', 'required');
$this->form_validation->set_rules('cname', 'College Name', 'required');
$this->form_validation->set_rules('dob', 'Date of Birth', 'required|callback_valid_date');
$this->form_validation->set_rules('addr', 'Address', 'required');
$this->form_validation->set_rules('contact', 'Contact', 'required|min_length[10]|max_length[10]');
$this->form_validation->set_rules('education', 'Education', 'required');
$this->form_validation->set_rules('user_email', 'Email', 'required|valid_email|is_unique[users.email]');
if ($this->form_validation->run() == FALSE)
{
$this->session->set_flashdata('result', validation_errors());
redirect('login/register');
}
else
{
$rr = $this->user->register_user();
$this->session->set_flashdata('result', $rr);
redirect('login/register');
}
}
基本上使用$ this-> session-> flashdata(「result」);顯示結果,但我希望每個字段單獨驗證我已經嘗試過form_error(「字段名稱」);但它不起作用顯示空的結果如何顯示codeigniter中的每個字段上的錯誤
相反重定向嘗試,如果有任何驗證錯誤加載相同的形式的。 –