关于电子邮件被使用两次,我遇到了问题。它不打印通知用户他已经使用了该电子邮件。我之前有它工作,但是在添加密码确认字段后它停止工作。我想要它做的是打印"电子邮件无效或已被采取。"当电子邮件再次注册时。
if ($count==0) {
if ($_POST["password"] == $_POST["confirm_password"]) {
$query = "INSERT INTO login(username,email,password) VALUES('$username','$email','$encrypt')";
if ($dbConnect->query($query)) {
$alert = "<div class='alert alert-success'>
<span class='glyphicon glyphicon-info-sign'></span> Registered successfully!
</div>";
}else {
$alert = "<div class='alert alert-danger'>
<span class='glyphicon glyphicon-info-sign'></span> Error try again or contact web master!
</div>";
}
} else {
$alert = "<div class='alert alert-danger'>
<span class='glyphicon glyphicon-info-sign'></span> Email is invalid or already taken.</div>";
}
}
&#13;
答案 0 :(得分:2)
您将电子邮件存在代码块放在if($count == 0)
块中。它不应该存在。它将在其他块中。使用以下代码。
if ($count==0)
{
if ($_POST["password"] == $_POST["confirm_password"])
{
$query = "INSERT INTO login(username,email,password) VALUES('$username','$email','$encrypt')";
if ($dbConnect->query($query))
{
$alert = "<div class='alert alert-success'>
<span class='glyphicon glyphicon-info-sign'></span> Registered successfully!
</div>";
}
else
{
$alert = "<div class='alert alert-danger'>
<span class='glyphicon glyphicon-info-sign'></span> Error try again or contact web master!
</div>";
}
}
}
else
{
$alert = "<div class='alert alert-danger'>
<span class='glyphicon glyphicon-info-sign'></span> Email is invalid or already taken.</div>";
}