0
我一直在調整我從教程和其他帖子看到的唯一的電子郵件驗證代碼。然而,對我的代碼來說,沒有任何東西可以完美工作唯一的電子郵件地址驗證
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.");
}
我評論過的幾行,因爲他們並沒有無論如何工作。我檢查了我的系統/庫/ form_validation,它似乎是正確設置。
這似乎工作,因爲每當我鍵入相同的電子郵件添加測試,電子郵件添加字段以黃色突出顯示。但沒有消息顯示,而且,表格仍然提交.. – user3453256
哦,我明白了。我做了:$ this-> form_validation-> set_rules('c_eadd','Email Address','required | trim | xss_clean | valid_email | is_unique [client.email_address]'); \t \t \t \t \t \t如果($這個 - > form_validation->的run()== FALSE) \t \t \t { \t \t回聲「'; \t \t $ this-> load-> view('client_signup'); \t \t \t}否則{\t \t $ \t這 - > in_model-> register_client($ _ POST);但是,我想在輸入相同的電子郵件地址後立即提醒用戶。在我能做的解決方案中,它仍然繼續,直到最後一個字段.. – user3453256