PHP / MYSQL:检查数据库中是否存在电子邮件?

时间:2015-12-12 04:57:19

标签: php mysql

在验证电子邮件地址以检查它是否存在于数据库中时遇到一些问题。它仍然提交表格。我不知道查询是否存在问题,或者它是否无效。任何帮助将不胜感激。

CODE:

<?php
if(isset($_POST['reg']))
{
$email = $_POST['login_email'];
$checkqry = "SELECT * from clinic_receptionist WHERE recep_email = '$email'";
$checkresult = mysqli_query($conn,$checkqry);
if(mysqli_num_rows($checkresult) > 0)
{
    echo "THE EMAIL ADDRESS IS IN USE";
}
}
?>
<form action="create_profile.php" method="post">

    <label>Email Address</label>
    <input type="email" name="login_email" id="login_email" class="form-control" placeholder="Email Address" required oninvalid="setCustomValidity('Please enter your email address')">
    <label>Password</label>
    <input type="password" name="password" class="form-control" placeholder="Password" required oninvalid="setCustomValidity('Please enter your password')">


    <input type="submit" name="reg" value="Register" class="btn btn-primary" style="margin-left:6%;">
<div style=" margin-top:4%;">
    <a href ="index.php" target="_blank" style="margin-left:6%;">Already have an Account? - Login</a>
</div>
</form>

1 个答案:

答案 0 :(得分:1)

查询应该是这样的:

$email = $_POST['login_email'];
$checkqry = "SELECT * from clinic_receptionist WHERE recep_email = '$email' ";