In general, here is the processing script, here it is simple, first the stlen field is checked, then it is checked for the repetition of the password; login is busy, displays, but in the loop, login is busy login is busy, etc. It seems to be correctly written, but if in a cycle, then there will be as many records displayed as there are records in the database, how to get out of this impasse.

$userstable = mysql_query("SELECT * FROM users"); if(strlen($name) > 1 AND strlen($email) > 1 AND strlen($music) > 1 AND strlen($password > 1 AND strlen($repassword) > 1){ if($password == $repassword){ while($relogin = mysql_fetch_array($userstable)){ if($name != $relogin['name']){ $insertusersdb = mysql_query("INSERT INTO users (`name`, `email`, `genre`, `password`) VALUES ('$name', '$email', '$music', '$password')"); echo '<script>$("#submitregister").html("Идет регистрация...");</script>'; if($insertusersdb == true){ echo ' <script>setTimeout(function(){ $("#register-block").css("margin-top","-295px"); $("#errormass").fadeOut(250).empty(); $("#submitregister").html("Заригестрироваться").fadeIn(2000); $("#formregistrationmain")[0].reset(); },2000); $("#submitregister").html("Регистрация завершена"); </script>'; echo '<p style="color:green;">Спасибо за регистрацию</p>'; } } else{ echo 'Извените, но такой логин уже занят!'; } } } } 

    1 answer 1

    on the topic, and why not restrict one request to the database to match the login?

     SELECT 'name' FROM users WHERE 'name'="{$user_entered_name}" 

    and if there is a result, then do not give to register. why go through the whole base?
    By the way, according to your logic, the very first mismatch initiates writing to the database :)

    • Yes, I know, it is processed by Ajax, the main thing is working, but I tried to check the nickname problem, I tried yours, exactly, right) I tested it, there is no answer at all - trix
    • not coming? Perhaps the answer should be in the form of json'a? javascript code would not hurt. + Maybe there is still some error, turn on the error display and see the response from the server to the firebug type. - thunder