php - Method to check if username exists in database -


i have method checks if username exists in database:

public function checkusername($username)  {      global $wpdb;     $result = $wpdb->get_row( "select * {$wpdb->prefix}users con_username =".$username);     if(!empty($result)){          return false;     }  } 

i checking username so:

if(!$users->checkusername($_post['email'])){         $error++;         $error_msg[]='email exists!';     } 

however isnt working telling me every username try exists. dont think have returns written correctly.. ideas??

you not returning if email not found , checkusername return null in case.

$users->checkusername($_post['email']) empty or null.

try -

return empty($result); 

the function should -

public function checkusername($username)  {      global $wpdb;     $result = $wpdb->get_row( "select * {$wpdb->prefix}users con_username ='".$username."'");     return empty($result);  } 

and check -

if(!$users->checkusername($_post['email'])){ 

and try implement security input data.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -