2015-01-01 78 views
1

我試着用電子郵件確認做一個登錄系統,所以當用戶確認電子郵件時,數據庫中的哈希值從MD5值變爲「確認」,然後在logon.php我用:

if (isset($_POST['submit'])) 
{ 
    $confirmed = 'confirmed'; 
    $username = $_POST['username']; 
    $password = $_POST['password']; 

    $query = "SELECT id, username FROM users WHERE username = ? AND hash = ? AND password = SHA(?) LIMIT 1"; 
    $statement = $databaseConnection->prepare($query); 
    $statement->bind_param('sss', $username, $password, $confirmed); 

    $statement->execute(); 
    $statement->store_result(); 

    if ($statement->num_rows == 1) 
    { 
     $statement->bind_result($_SESSION['userid'], $_SESSION['username']); 
     $statement->fetch(); 
     header ("Location: index.php"); 
    } 
    else 
    { 
     echo "Username/password combination is incorrect."; 
    } 
} 

我已經嘗試了一切,但$statement->num_rows總是返回0,任何人都可以幫助我嗎?請

+0

作爲預留不,把你的'header'重定向行之後的'exit' –

回答

-1

我認爲你正在尋找

$statement->rowCount() 

我希望幫助