检查电子邮件是否已存在于数据库中 - 不起作用

Check if email already exists in database - not working

我想在注册时检查数据库中是否已存在电子邮件,但无法正常工作。尽管我为此进行了检查,但它并没有检查电子邮件是否已经存在。非常感谢任何帮助。

<?php 
    if(!empty($_POST)){
        $email = $_POST['email'];
        $question1 = $_POST['question1']; 
        $question2 = $_POST['question2']; 
        $question3 = $_POST['question3']; 
        $question4 = $_POST['question4']; 
        $question5 = $_POST['question5']; 
        $question6 = $_POST['question6']; 
        $question7 = $_POST['question7']; 
        $question8 = $_POST['question8']; 
        $question9 = $_POST['question9']; 
        $question10 = $_POST['question10']; 
        $question11 = $_POST['question11']; 
        $question12 = $_POST['question12']; 
        $question13 = $_POST['question13']; 
        $question14 = $_POST['question14']; 
        $question15 = $_POST['question15']; 

    }

        $mysqli = new mysqli('localhost', 'root', '', 'database');

        $check="SELECT * FROM applications WHERE email = '$email'";
        $rs = mysqli_query($mysqli,$check);
        $data = mysqli_fetch_array($rs, MYSQLI_NUM);
        if($data[0] > 1) {
            echo "User Already in Exists<br/>";
        }
        else
        {

        $queryResult =  $mysqli->query("INSERT INTO applications(email, question1, question2, question3, question4, question5, question6, question7, question8, question9, question10, question11, question12, question13, question14,question15) VALUES ('$email', '$question1', '$question2', '$question3', '$question4', '$question5', '$question6', '$question7', '$question8', '$question9', '$question10','$question11', '$question12', '$question13','$question14', '$question15')");

if ($queryResult === TRUE) {
    echo"<div class='container padtop100'>
            <div class='row'>
                <div class='col-lg-12'>
                    <div class='panel panel-default'>
                        <div class='panel-heading'>
                            <h3 class='panel-title uppercase'>
                                Success!
                            </h3>
                        </div>
                        <div class='panel-body'>
                            <span>Thank your for your application, ${question1}.</span><br /><br />Your application has now been recorded, and is pending review. You will be notified via email on how to proceed, once your application has been reviewed. You may also check the status on your application <a href='index.php/index'>here</a>.</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>";
    } else {
    echo "Error: ";
    }
        }
?>

使用这个查询:

$check="SELECT COUNT(email) FROM applications WHERE email = '$email'";