我無法使用password_verify驗證密碼。我使用BCRYPT進行密碼散列。幫我在這段代碼發現錯誤,我怎麼在下面的select語句綁定變量:PHP密碼驗證
<?php
if (isset($_POST['submit'])) {
// echo "ok";
$con = connect();
$email = $_POST['email_id'];
$pass_word = $_POST['pass_word'];
if ($con) {
$query = mysqli_query($con,"select * from login where email_id='".$email."'");
$rows = mysqli_num_rows($query);
if ($query) {
$row = mysqli_fetch_assoc($query);
if ($row) {
$hash = $row['password'];
if (password_verify($pass_word,$hash) {
echo '<strong>Successful' ;
} else {
echo "Invalid Password";
}
}
}
} else {
die("Connection Error");
}
}
?>
其實這是由於複製mistake.Then我意識到,我沒有散列密碼全部。所以這不是working.Thanks反正。如何在選擇語句中綁定變量 – shubhamj
'「select * from login where email_id = $ email」'這將工作,因爲查詢是雙引號的,您可以使用插值 – Afsar
閱讀本文,http://stackoverflow.com/問題/ 16790501/php-variable-interpolation-vs-concatenation會幫助你 – Afsar