我正在創建一個應用程序...一切都很好。在我的註冊系統中使用了準備好的語句和密碼散列,並且也嘗試驗證我的表單字段中的用戶輸入。爲了完成這個系統,我需要創建一個忘記的密碼系統,這意味着用戶可以申請新的密碼。忘記密碼沒有更新加密碼哈希
做了什麼是我有一個測試網站與所有的文件,這意味着我可以測試之前,將其添加到生產網站的作品。
隨着忘記密碼用過一次mysqli的一切工作正常的話,我會更新,以準備,因爲我仍然在學習準備好的聲明,並做這種方式幫助我瞭解,所以不要判斷。
我忘了密碼的問題是密碼不更新一次更改。請參閱此屏幕截圖:http://prntscr.com/d5hage
此外,如上所述,在我的註冊中使用了http://prntscr.com/d5hbg1,並在我的登錄中進行驗證。但是如何在我忘記的密碼中使用哈希或我如何更新它。在我的代碼中使用了md5,我知道它已經損壞。請在下面填寫我的所有代碼
Reset_Password.php
<?php
// include connection
require_once('include/connection.php');
if(isset($_POST['submit'])){
$user_id = base64_decode($_GET['encrypt']);
$passnew = password_hash($password, $_POST['new_password'], PASSWORD_BCRYPT, array('cost' => 12));
$sql = "UPDATE `olami560_test`.`user` SET `password` =? WHERE `user`.`id` =?";
$stmt = $con->prepare($sql);
$stmt->bind_param('si',$passnew, $user_id);
$stmt->execute();
if ($stmt->errno) {
echo "FAILURE!!! " . $stmt->error;
}
else echo "Password Changed Successfully.Click on link to login <a href='http://www.olaskee.co.uk/project/allocation/progress/index.php'>Login</a>{$stmt->affected_rows} rows";
$stmt->close();
}
?>
<form method="post" action="<?php echo $_SERVER['HTTP_REFERER']; ?>" >
<label>New Password</label>
<input type="password" name="new_password"/>
<input type="submit" name="submit" value="Reset" />
</form>
forgot_password.php
<?php
// include connection
require_once('include/connection.php');
if(isset($_GET) && !empty($_GET['email'])){
$email = mysqli_real_escape_string($con,$_GET['email']);
$query = "SELECT id
FROM `user`
WHERE `user_name` LIKE '".$email."'
OR `email` LIKE '".$email."'";
$result = mysqli_query($con,$query);
$Results = mysqli_fetch_array($result);
if(count($Results)>=1)
{
$query2 = "SELECT email
FROM `user`
WHERE `user_name` LIKE '".$email."'
OR `email` LIKE '".$email."'";
$result2 = mysqli_query($con,$query2);
$emailvalue = mysqli_fetch_array($result2);
//$token = md5(uniqid(rand(),true));
//$encrypt = md5($Results['id']);
$encrypt = base64_encode($Results['id']);
$message = "Your password reset link send to your e-mail address.";
$to = $emailvalue['email'];
$subject="Forget Password";
$from = '[email protected]';
$body= 'Hi, <br/> User <br/>You Requested for Reset Password. <br><br>http://www.olaskee.co.uk/project/allocation/tms/reset_password.php?token='.$token.'&encrypt='.$encrypt.'&action=reset<br/> <br/>--<br>.olaskee<br>';
$headers = "From: " . strip_tags($from) . "\r\n";
$headers .= "Reply-To: ". strip_tags($from) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to,$subject,$body,$headers);
echo $message;
}
else
{
$message = "Account not found please signup now!!";
echo $message;
}
}
?>
我希望有提供足夠的解釋讓你瞭解。感謝任何輸入。
您的屏幕截圖使用'password_hash',爲什麼不使用完全相同的功能呢? – apokryfos
爲什麼被拒絕投票......我的要求或問題有任何問題。請分享您的意見。謝謝 – Olaskee
當我使用注意事項時,我仍然得到0行更新 – Olaskee