Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 电子邮件可用性检查返回每个电子邮件的可用性_Php_Html_Jquery_Pdo - Fatal编程技术网

Php 电子邮件可用性检查返回每个电子邮件的可用性

Php 电子邮件可用性检查返回每个电子邮件的可用性,php,html,jquery,pdo,Php,Html,Jquery,Pdo,表单提交的HTML代码: <div class="control-group"> <label class="control-label" for="input01">Email</label> <div class="controls"> <input type="text" class="input-xlarge" id="email" name="email" rel="popove

表单提交的HTML代码:

<div class="control-group">
    <label class="control-label" for="input01">Email</label>
    <div class="controls">
         <input type="text" class="input-xlarge" id="email" name="email" 
         rel="popover" data-content="What’s your email address?" 
         data-original-title="Email">
        <span class="check" style="color:red;" ></span>
    </div>
</div>

对于输入的每封电子邮件,它都返回“可用”。我的数据库中有几封我正在使用的电子邮件。我在控制台中也没有收到任何错误。

您从
Consultants
表中选择了所有字段,因此第一列的计算结果可能大于0

此外,您准备的语句不应在绑定参数
:email
周围使用引号

要修复:

$stmt = $db->prepare("SELECT COUNT(*) FROM `Consultants` WHERE email =:email");

如果($num_rows>0){$HTML='Unavailable';}或者{$HTML='available';}那么jQuery的编辑-if(result=='available'){…仍然返回一封不可用的电子邮件,很遗憾!@BenLittle更新了答案,您准备的语句还有另一个问题。
include_once "../base.php";

$stmt = $db->prepare("SELECT * FROM `Consultants` WHERE email =':email'");
$stmt->bindParam(":email", $_POST['email']);
$stmt->execute();

$num_rows = $stmt->fetchColumn();
$HTML='';
if($num_rows > 0){
    $HTML='is already used';
}else{
    $HTML='';
}
echo $HTML;

$stmt = null;
$stmt = $db->prepare("SELECT COUNT(*) FROM `Consultants` WHERE email =:email");