Constantly writes that Login is busy: Here is the check from the database itself (everything works correctly, it transmits false or true)

if($_SERVER['REMOTE_ADDR'] == 'POST') { include "../conect/connection.php"; include "../functions/functions.php"; $login = clear_string($_POST['reg_login']); $result = mysql_query("SELECT login FROM reg_user WHERE login = '".$login."' "); if (mysql_num_rows($result) > 0) { echo 'false'; } else { echo 'true'; } } 

but still writes that the login is busy, even if the handler reported that it is not in the database

 $(document).ready(function() { $('#form_reg').validate({ // ΠΏΡ€Π°Π²ΠΈΠ»Π° для ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠΈ rules: { "reg_login": { required: true, minlength: 5, maxlength: 15, remote: { type: 'post', url: "reg/check_login.php" } }, "reg_pass": { required: true, minlength: 7, maxlength: 15 }, "reg_surname": { required: true, minlength: 3, maxlength: 15 }, "reg_name": { required: true, minlength: 3, maxlength: 15 }, "reg_patronymic": { required: true, minlength: 3, maxlength: 25 }, "reg_email": { required: true, email: true }, "reg_phone": { required: true }, "reg_address": { required: true }, "reg_captcha": { required: true, remote: { type: "post", url: "reg/check_captcha.php" } } }, // Π²Ρ‹Π²ΠΎΠ΄ΠΈΠΌΡ‹Π΅ сообщСния ΠΏΡ€ΠΈ Π½Π°Ρ€ΡƒΡˆΠ΅Π½ΠΈΠΈ ΡΠΎΠΎΡ‚Π²Π΅Ρ‚ΡΡ‚Π²ΡƒΡŽΡ‰ΠΈΡ… ΠΏΡ€Π°Π²ΠΈΠ» messages: { "reg_login": { required: "Π£ΠΊΠ°ΠΆΠΈΡ‚Π΅ Π›ΠΎΠ³ΠΈΠ½!", minlength: "ΠžΡ‚ 5 Π΄ΠΎ 15 символов!", maxlength: "ΠžΡ‚ 5 Π΄ΠΎ 15 символов!", remote: "Π›ΠΎΠ³ΠΈΠ½ занят!" }, "reg_pass": { required: "Π£ΠΊΠ°ΠΆΠΈΡ‚Π΅ ΠŸΠ°Ρ€ΠΎΠ»ΡŒ!", minlength: "ΠžΡ‚ 7 Π΄ΠΎ 15 символов!", maxlength: "ΠžΡ‚ 7 Π΄ΠΎ 15 символов!" }, "reg_surname": { required: "Π£ΠΊΠ°ΠΆΠΈΡ‚Π΅ Π²Π°ΡˆΡƒ Ѐамилию!", minlength: "ΠžΡ‚ 3 Π΄ΠΎ 20 символов!", maxlength: "ΠžΡ‚ 3 Π΄ΠΎ 20 символов!" }, "reg_name": { required: "Π£ΠΊΠ°ΠΆΠΈΡ‚Π΅ вашС Имя!", minlength: "ΠžΡ‚ 3 Π΄ΠΎ 15 символов!", maxlength: "ΠžΡ‚ 3 Π΄ΠΎ 15 символов!" }, "reg_patronymic": { required: "Π£ΠΊΠ°ΠΆΠΈΡ‚Π΅ вашС ΠžΡ‚Ρ‡Π΅ΡΡ‚Π²ΠΎ!", minlength: "ΠžΡ‚ 3 Π΄ΠΎ 25 символов!", maxlength: "ΠžΡ‚ 3 Π΄ΠΎ 25 символов!" }, "reg_email": { required: "Π£ΠΊΠ°ΠΆΠΈΡ‚Π΅ свой E-mail", email: "НС ΠΊΠΎΡ€Ρ€Π΅ΠΊΡ‚Π½Ρ‹ΠΉ E-mail" }, "reg_phone": { required: "Π£ΠΊΠ°ΠΆΠΈΡ‚Π΅ Π½ΠΎΠΌΠ΅Ρ€ Ρ‚Π΅Π»Π΅Ρ„ΠΎΠ½Π°!" }, "reg_address": { required: "НСобходимо ΡƒΠΊΠ°Π·Π°Ρ‚ΡŒ адрСс доставки!" }, "reg_captcha": { required: "Π’Π²Π΅Π΄ΠΈΡ‚Π΅ ΠΊΠΎΠ΄ с ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠΈ!", remote: "НС Π²Π΅Ρ€Π½Ρ‹ΠΉ ΠΊΠΎΠ΄ ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠΈ!" } }, submitHandler: function(form) { $(form).ajaxSubmit({ success: function(data) { if (data == 'true') { $("#block-form-registration").fadeOut(300, function() { $("#reg_message").addClass("reg_message_good").fadeIn(400).html("Π’Ρ‹ ΡƒΡΠΏΠ΅ΡˆΠ½ΠΎ зарСгистрированы!"); $("#form_submit").hide(); }); } else { $("#reg_message").addClass("reg_message_error").fadeIn(400).html(data); } } }); } }); }); 

Here is the connection to the database

 $connection = mysql_connect ("localhost", "root", ""); $db = mysql_select_db ("goodvac"); mysql_set_charset("utf8"); if(!$connection || !$db) { exit(mysql_error()); } 
  • Give the error code and probably the 'connection.php' code, as well as the database structure and entries in it, and what you transmit. ps it is desirable to use the prepared statement for such things, instead of dancing with string concatenation - Ep1demic

1 answer 1

In the first line:

 if($_SERVER['REMOTE_ADDR'] == 'POST') 

The request method is contained in $_SERVER['REQUEST_METHOD'].

  • thanks for the answer. I also tried this option, but checking it against the DB does not work at all - Ruslan Liashenka