这些类型的字段只能意味着一件事。我是否正确您将它们用于用户更改密码表单?在这种情况下:
//Below means that the user required to fill in all 3 of the fields. None of them must return false (be left blank)
if ($this->input->post('current_password') && $this->input->post('new_password') && $this->input->post('repeat_password') ) {
return true;
} else {
return false;
}
但是,codeigniter 支持使用表单验证器检查表单字段的更好方法:
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('newpass', 'New password', 'required');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
if ($this->form_validation->run() == FALSE) {
$this->load->view('myform');
} else {
$this->load->view('formsuccess');
}