如何验证来自数据库的电子邮件?

时间:2017-05-22 17:06:04

标签: php mysql

我尝试从我的数据库验证并发送电子邮件,但它不会检查它是否存在,请问它是如何解决的? 在这里,我已经尝试过了;

<?php
function SignIn()
{
    $con=mysqli_connect("localhost", "root", "password007", "voting");

    $email = $_POST['email'];

if(!empty($email))   //checking the 'user' name which is from Sign-In.html, 
is it empty or have some text
{
    $query = mysqli_query($con,"SELECT Email, VotersID FROM voters where Email = '$email' ");
    $row = mysqli_fetch_array($query);
    if(!empty($row['Email']))
    {

        $_SESSION['Email'] = $row['Email'];
        $votersID = $row['VotersID'];

        echo '<script type="text/javascript">window.onload=function(){alert("Message have been sent to your email.");}</script>';


    }
    else{
        echo '<script type="text/javascript">window.onload=function(){alert("Email not found! Please try again.");}</script>';
    }
}
}
if(isset($_POST['btn']))
{
    SignIn();
}
          ?>

0 个答案:

没有答案