3 回答

TA貢獻1853條經(jīng)驗 獲得超9個贊
朋友,因為我們使用唯一的用戶名登錄,因此我們必須僅使用用戶名從數(shù)據(jù)庫中獲取密碼/數(shù)據(jù)。
例:
<?php
$connect = mysqli_connect($localhost, $username, $pwd, $database) or die("Opps some thing went wrong");
if (isset($_POST['submit'])) {
extract($_POST);
// Get Old Password from Database which is having unique userName
$sqlQuery = mysqli_query($connect, "select * from loginTable where User='$username'");
$res = mysqli_fetch_array($sqlQuery);
$current_password = $res['userPassword'];
if (password_verify($enteredPassword, $current_password)) {
/* If Password is valid!! */
$_SESSION['id'] = $res['id'];
header("location: home.php");
}
else {
/* If Invalid password Entered */
$alt = "Login Failed! Wrong user ID or Password";
header("location: index.php?m=$alt");
}
}
?>
它正在為我工作...我正在從數(shù)據(jù)庫中獲取密碼,并使用PHP API與輸入的密碼進行比較,即password_verify($ enteredPassword,$ current_password)

TA貢獻2041條經(jīng)驗 獲得超4個贊
您讓我檢查數(shù)據(jù)庫字段長度是正確的。不是255,那是打破它的原因。非常感謝您幫助我解決這個問題。我也在研究準備好的語句,我習慣于手動阻止SQL注入,直到最近我才聽說過它們,到目前為止,我發(fā)現(xiàn)它們非常簡單。再次感謝您的幫助。
- 3 回答
- 0 關注
- 965 瀏覽
添加回答
舉報