我一直在调整我在教程和其他帖子中看到的独特的电子邮件验证代码。然而,似乎没有什么能完美地适用于我的代码。
public function register_client($post_obj)
{
//client registration
$record = array
(
'first_name' => $post_obj['c_fname'],
'last_name' => $post_obj['c_lname'],
'email_address' => $post_obj['c_eadd'],
'password' => $post_obj['c_pword'],
'address' => $post_obj['c_add'],
'tagline' => $post_obj['c_tagline'],
'profile' => $post_obj['c_profile'],
'interests' => $post_obj['c_interest'],
'billing_mode' => $post_obj['c_bmode']
);
$this->db->insert('client', $record);
}
在我的控制器中,我有这个:
public function client_signup_submit()
{
// completes client registration
/*$post_email = $this->input->post('c_eadd');
$this->form_validation->set_rules('c_eadd', 'Email Address', 'required|trim|xss_clean|valid_email|callback_check_duplicate_email[' . $post_email . ']');
$this->form_validation->set_message('check_duplicate_email', 'This email already exits. Please write a new email.');
if ($this->form_validation->run() == FALSE) {
// validation failed then do that
$this->load->view('client_signup');
} else */
//$this->form_validation->set_rules('c_eadd',Email,'trim|xss_clean|required|valid_email|callback_check_email_exists');
$this->inspire_model->register_client($_POST);
redirect("in/client?message=Client Account Registration Completed.");
}
我已经评论了几行,因为它们无论如何都不起作用。我检查了我的system/librarys/form_validation,它似乎设置正确。
为什么不按照文档所说的去做:is_unique[users.email]
,其中users
是表,email
是要检查的字段。http://ellislab.com/codeigniter/user-guide/libraries/form_validation.html
$this->form_validation->set_rules('c_eadd',
'Email Address',
'required|trim|xss_clean|valid_email|is_unique[users.email]');