Friends, I have such a question! There is a registration form! This ajax
script is hung on it
$.ajax({ type: "POST", data: "key=" + em, url: "/proverka.inc.php", dataType: "json", success:function(data){ if(data.key == "error") { $("#proverka2").text("Данный email уже используется!"); } else { $("#proverka2").text("ok"); } } });
it is sent to php
script
<?php session_start(); include('dbcon.inc.php'); if($_POST) { $key = $_POST['key']; mysql_select_db(DB_NAME); $query = "SELECT * FROM users"; $result = mysql_query($query); mysql_close(); while($myrow = mysql_fetch_assoc($result)) { if($myrow['email'] == $key) { $key = array("key" => "error"); echo json_encode($key); } } } ?>
the problem is that it works, when you redial the same mailbox, a notification goes out, saying that such an email already exists, but if you enter the original email (which is not in the database), the email does not change and the notification does not disappear. Here would be to me)