-4
我正在嘗試檢查註冊時數據庫中是否已存在電子郵件,但我無法使其工作。儘管我爲此付了檢查,但並不檢查電子郵件是否存在。將不勝感激任何幫助。檢查數據庫中是否已存在電子郵件 - 不工作
<?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: ";
}
}
?>
可能重複[檢查用戶名數據庫MySQL的PHP已經存在(http://stackoverflow.com/questions/8611044/check-if-username-已經存在的功能於數據庫的MySQL-PHP) – 2015-02-10 11:37:49