这是 codeigniter 中的一个简单的登录验证脚本。我无法理解这个问题。我已经阅读了用户指南,但回调不起作用。
public function form_validation()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required|trim |alpha_numeric');
$this->form_validation->set_rules('password', 'Password', `enter code here` 'required|trim |xss_clean');
$this->form_validation->set_rules('email', 'Email', 'required|trim|valid_email|xss_clean|callback_validate');
if ($this->form_validation->run()) {
echo "validated but not logged";
} else {
$this->load->view('errors/formerror');
}
}
public function validate()
{
$this->load->model('model_users');
if ($this->model_users->can_login()) {
echo "Logged";
} else {
$this->form_validation->set_message('validate', "Incorrect username/password");
}
}