我一直在调整我从教程和其他帖子中看到的唯一电子邮件验证码。但是,对我的代码来说似乎没有任何效果。
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 / libraries / form_validation,似乎它已正确设置。
答案 0 :(得分:0)
为什么不做文档所说的内容: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]');