我有一些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 check.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";
}
}