如果电子邮件已存在于数据库中,我正在尝试检查电子邮件字段模糊。我的代码现在是:
<script type="text/javascript">
$(document).ready(function () {
// Validation
$("#soutez").validate({
rules: {
email: {
required: true,
email: true,
remote: "check-email.php",
},
},
messages:{
email:'Email address exists.'
},
onkeyup: false,
onblur: true,
});
});
</script>
而php代码是
$email= $_GET['email'];
echo $email;
$path = $_SERVER['DOCUMENT_ROOT'];
include_once $path . '/wp-config.php';
include_once $path . '/wp-load.php';
include_once $path . '/wp-includes/wp-db.php';
include_once $path . '/wp-includes/pluggable.php';
global $wpdb;
$email_exists = $wpdb->get_row('SELECT COUNT(*) as count from reg_form_new WHERE email = "'.$email.'"');
if ( $email_exists->count == 0 ) { echo 'true'; } else { echo 'false'; }
exit; }
php 代码正确返回 true/false,但由于某种原因,它不适用于 jQuery 脚本。谁能告诉我我做错了什么?谢谢