Hello!

I redo the store script from mysql to mysqli. I did the main thing, but I can’t cope with checking the login login. User data is written to the database. Here is the code (here, when registering when a login is busy, a warning appears):

function check_login($user) { db_connect(); $query = sprintf(" SELECT username FROM users WHERE users.username = '%s' ", mysqli_real_escape_string($user)); $result = mysqli_query($query); if(mysqli_num_rows($result) > 0) return FALSE; else return TRUE; } 

Here is the new code (here the user with the same login is entered into the database again):

 function check_login($user) { global $link; $query = sprintf(" SELECT username FROM users WHERE users.username = '%s' ", mysqli_real_escape_string($user)); $result = mysqli_query($link, $query); if(mysqli_num_rows($result) > 0) return FALSE; else return TRUE; } 

Thanks in advance for your help!

  • Good people, absolutely nothing .. ?? - arhat78

1 answer 1

Try to do as here . It will be even more correct.

  • A1essandro, I read this post, but I didn’t take anything for myself ... It turns out that the check_login check fails, and with the same login the user is registered .... - arhat78
  • @ A1essandro, Try to write more detailed answers. Explain what your statement is based on. - Nicolas Chabanovsky