简体   繁体   English

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

[英]PHP/MYSQL: Check whether email exists in database?

Having a bit of an issue validating the email address to check whether it exists in the database. 验证电子邮件地址以检查其是否存在于数据库中时出现问题。 It still submits the form. 它仍然提交表格。 I don't know if it there is an issue with the query or if it just won't work. 我不知道查询是否存在问题或是否行不通。 Any help will be greatly appreciated. 任何帮助将不胜感激。

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>

Query should be like this: 查询应该是这样的:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM