php - if else statement is not working on codeigniter -
i have few if else statement on returning true or false, , every statement not working properly. have tried many ways don't know problem.it helpful if fix this.
here code model
function exists($email){ $this->db->where('email',$email); $query=$this->db->get('member_info'); echo "model called"; // after execution text shown not others if ($query->num_rows == 1) { return true; echo "i got one"; }else{ return false; echo "i got nothing"; } }
and here controller
function is_exists($email){ echo "this loaded"; //this line works if($this->validation_model->exists($email)){ return false; echo "true"; //this doesn't }else{ return true; echo "false"; // doesn't } }
you returning function before print echo part. should echo before return.
also change line check more one
if ($query->num_rows() > 0 ) {
update
try method. replace table name, id value accordingly.
$query = $this->db->query("select id form your_table email=".$email); if ($query->num_rows() > 0 ){ echo "i got one"; return true; } else{ echo "i got nothing"; return false; }
also @ controller logic return false when there exist email. better change true false returning of controller.
Comments
Post a Comment