是否有人知道如何更正此代碼,以便識別電子郵件是否已存在於數據庫中並顯示錯誤。這是目前顯示錯誤消息,即使該電子郵件不存在於數據庫中 - 因此形式沒有得到提交:正確識別數據庫中是否存在電子郵件的問題 - PHP
$email = $_POST['email'];
//prepare and set the query and then execute it
$stmt = $conn2->prepare("SELECT COUNT(email) FROM users WHERE email = ?");
$stmt->bind_param('s', $email);
$stmt->execute();
// grab the result
$stmt->store_result();
// get the count
$numRows = $stmt->num_rows();
if($numRows)
{
$errors = true;
echo "<p class='red'>Email is already registered with us</p>";
}
else
//if we have no errors, do the SQL
這段代碼有什麼問題? – apis17 2012-02-24 19:14:23
更多有用的相關信息:http://stackoverflow.com/questions/2700621/php-pdo-num-rows – 2012-02-24 19:16:57
看到我的編輯 – 2012-02-24 19:19:30