使用数据模型弹出通过ajax在数据库中检查和插入电子邮件

时间:2015-12-17 07:49:02

标签: javascript ajax codeigniter

public function register()
    {   

        $this->load->library('form_validation');
        $this->form_validation->set_rules('email','email','required|is_unique[register.email]');
        if($this->form_validation->run() == FALSE){



            $this->load->view('view/login_register');
            $this->session->set_flashdata('message_error','This id is already taken');

        }
        else
        {
           ///$username=$this->input->post('username');
            $email=$this->input->post('email');
            $data= array(

             ////'email'=>$this->input->post('email')
                'email'=>$email,   
          //'password'=>$this->input->post('password'),
                );

            $last_id=$this->model->registeration($data);

            if ($last_id>0) {

                $this->send_email($email);


                $this->session->set_flashdata('message', 'To complete registration, click the link in email we just send you at khadija@precisetech.com.pk');
                redirect('controller/register');
            }


        } 
    if(error_flag == 1){
      return false;
    }else{
      return true;
    }
  }

如果Id存在,如何通过Ajax给出id已经存在的消息,数据模型弹出窗口应该没有刷新页面并在datamodel弹出窗口中显示消息意味着datmodel弹出窗口应该保持到消息成功或失败。

0 个答案:

没有答案