Hello!
I need that when a user enters a login he is immediately checked via php and mysql and if so, then false if not then true. I almost wrote the script, but the problem is that I do not know how to make it so that the array of values is already transferred to js.
Here is the script:
$("#name").blur(function () { if ($(this).val() != "") { var name = $(this).val(); $.ajax({ type: "POST", url: "test2.php", dataType: "json", success: function (data) { if (name == data.login) $("#go").text("Такой логин уже существует, попробуйте ввести другой!"); else $("#go").text("Этот логин свободный!"); } }); } else { $("#go").text(""); } });
Php file script:
mysql\_connect("localhost", "admin", "12345"); mysql\_select\_db("test_db"); $result = mysql\_query("SELECT * FROM test"); $myrow = mysql\_fetch\_array($result); echo json\_encode($myrow);
It is necessary that the ajax request immediately checks the array if there is such a login. In the usual ways, something didn’t work through the while (I didn’t see that clearly =)) Do not judge the script strictly, I don’t work with js for a long time =) Help, please!
ZY If you can tell everything in detail.