小编fol*_*ett的帖子

检查CodeIgniter中的重复数据尝试创建回调函数

我有一份登记表.在这里,我可以通过我的自定义检查重复的电子邮件是唯一的回调函数(不要尝试使用is_unique).但它不会返回任何东西.这是我的代码.

控制器 -

public function add_member () {

    $this->load->library('form_validation');

    $post_email = $this->input->post('email_id');
    $this->form_validation->set_rules('email_id', 'Email ID/ Username', 'required|trim|xss_clean|valid_email|callback_check_duplicate_email[' . $post_email . ']');
    $this->form_validation->set_rules('password', 'Your password', 'required|min_length[5]|max_length[12]|matches[confirm_password');
    $this->form_validation->set_rules('confirm_password', 'Password Confirmation', 'required');

    $this->form_validation->set_message('check_duplicate_email', 'This email is already exist. Please write a new email.');

    if ($this->form_validation->run() == FALSE) {
        // validation failed then do that

        $this->load->view('member/reg_form');

    } else {

        $data['email_id'] = $post_email;
        $data['password'] = MD5($this->input->post('password'));

        $insert = $this->Model_member->insert_data_to_db($data);

        if ($insert) {
            $success = "Wao ! You are successfully added to our community.";
            $this->session->set_flashdata('message_success', $success); …
Run Code Online (Sandbox Code Playgroud)

php mysql codeigniter duplicates

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

codeigniter ×1

duplicates ×1

mysql ×1

php ×1