我正在使用codeigniter表單驗證。但我有問題,即密碼匹配不適合我。當回調方法顯示「電子郵件不存在」時, 那時候,所有驗證都正常工作。php驗證錯誤
public function forget_password() {
$this - > form_validation - > set_rules('email', 'email', 'trim|required|valid_email|callback_verifyUser',
array(
'required' => 'You must enter your email!',
'valid_email' => 'Enter valid email!',
//'is_unique' => ' is already exists'
)
);
$this - > form_validation - > set_rules('password', 'password', 'trim|matches[confirm_password]|required|min_length[6]',
array(
'required' => 'You Must Enter Password',
'matches' => 'Password Must Match with Confirm_password',
'min_length' => 'Minimum contain 6 charaters',
)
);
$this - > form_validation - > set_rules('confirm_password', 'confirm_password', 'trim|required',
array(
'required' => 'You Must Enter Password',
)
);
if ($this - > form_validation - > run() === true) {
$this - > load - > view('forget-password');
$this - > load - > view('template/footer');
} else {
$this - > load - > view('forget-password');
$this - > load - > view('template/footer');
}
}
public function verifyUser() {
$email = $this - > input - > post('email');
if ($this - > e_model - > login_view($email)) {
$result = $this - > e_model - > reset($email);
$this - > session - > set_flashdata('flsh_msg', '<div class="alert alert-success text-center">New password created successfully!</div>');
redirect(current_url());
return true;
} else {
//$this->form_validation->set_message('verifyUser','Email does not exists!');
return false;
}
}
您不需要在數組的最後一個對象之後使用逗號(,)。 – Dray
是的,我已經刪除它,但它不起作用。 –