我正在创建一个应用程序...一切都很好。在我的注册系统中使用了准备好的语句和密码散列,并且也尝试验证我的表单字段中的用户输入。为了完成这个系统,我需要创建一个忘记的密码系统,这意味着用户可以申请新的密码。忘记密码没有更新加密码哈希
做了什么是我有一个测试网站与所有的文件,这意味着我可以测试之前,将其添加到生产网站的作品。
随着忘记密码用过一次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