how to check if username already exists in codeigniter

后端 未结 8 1327
无人共我
无人共我 2020-12-20 00:33

I am working on a site in codeigniter.I am not so expert using framework.Here I have to check if email already exists in database.I have coded the required functionality but

相关标签:
8条回答
  • 2020-12-20 01:10

    Just add is_unique[tablename.fieldname] rules to the form validation. for Example:

     array('field' => 'email', 'label' => 'Email', 'rules' => 'trim|required|valid_email|is_unique[users.email]'));
    
    0 讨论(0)
  • 2020-12-20 01:14

    Your Model is like

    $this->db->select('id');
    $this->db->where('email', $email);
    

    please tell the mysql from which table you want to get the record.

    $this->db->from('tablename');

    it would be like

    $this->db->select('id');
    $this->db->from('tablename');
    $this->db->where('email', $email);
    
    0 讨论(0)
提交回复
热议问题