我制作了一个php文件,根据用户请求向他发送一个链接以恢复他忘记的密码,网站向他发送包含令牌的电子邮件,然后在用户输入新密码后,他被重定向到页面以恢复其密码正确地重复它按下提交按钮我的问题是当我按下提交php文件忘记令牌并返回错误令牌无法识别时。
---------忘记密码:------------
production
---------恢复密码页面:---------------
<?php
include('./classes/DB.php');
if(isset($_POST['Resetpassword'])){
/*bass 7otta live server besta3mil php mail */
/*bi ma2anno ana bi local server ra7 esta3mil el token ka mail */
$cstrong = True;
$token = bin2hex(openssl_random_pseudo_bytes(64, $cstrong));
$email=$_POST['email'];
$user_id = DB::query('SELECT id FROM users WHERE email=:email', array(':email'=>$email))[0]['id'];
DB::query('INSERT INTO password_tokens VALUES (null, :token, :user_id)', array(':token'=>sha1($token), ':user_id'=>$user_id));
echo 'email sent';
}
?>
<h1>Forgot Password</h1>
<form action="forgot_password.php" method="post">
<input type="text" name="email" value="" placeholder="Email ...." required></p>
<input type="submit" name="Resetpassword" value="Reset Password"></p>
</form>