0

我有一些 ajax 代码将我的电子邮件输入字段发送到服务器,在那里它检查电子邮件是否存在于数据库中。但是,它没有给出任何回应。

HTML

<input type="text" name="email" id="email" /><span id="emailcheck"></span>

AJAX

$(document).ready( function () {
    $("#email").change(function(){
    var mail = $("#email").val();
        $.ajax({
            type: "POST",
            url: "check.php",
            data: "email="+ mail,
            succes: function(response){
                if(response == "email not ok"){
                $("#emailcheck").html("<strong>E-mail is already in use</strong>");
            }
        }
    });
});

});

PHP检查.php

include_once($pathdb);

if(isset($_POST['email'])){
    $email = $_POST['email'];
    $sql = "SELECT id FROM users WHERE mail='".$email."'";
    $query = mysqli_query($dbconnect, $sql) or die(mysqli_error());
    $email_check = mysqli_num_rows($query);

        if($email_check > 0){
    echo "email not ok";
    }
}
4

0 回答 0