Created
December 17, 2013 20:52
-
-
Save jawinn/8012422 to your computer and use it in GitHub Desktop.
CodeIgniter - Check username exists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//--------------------------------- | |
// EMAIL EXISTS (true or false) | |
//--------------------------------- | |
private function email_exists($email) | |
{ | |
$this->db->where('email', $email); | |
$query = $this->db->get('users'); | |
if( $query->num_rows() > 0 ){ return TRUE; } else { return FALSE; } | |
} | |
//--------------------------------- | |
// AJAX REQUEST, IF EMAIL EXISTS | |
//--------------------------------- | |
function register_email_exists() | |
{ | |
if (array_key_exists('email',$_POST)) { | |
if ( $this->email_exists($this->input->post('email')) == TRUE ) { | |
echo json_encode(FALSE); | |
} else { | |
echo json_encode(TRUE); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment