正如我现在拥有的那样,任何用户都可以在 forgot.php 页面上键入电子邮件,如果电子邮件存在,则分配给该电子邮件密码的用户将被更改。我将如何更改我的代码,以便它向用户电子邮件发送一个链接,该链接指向他们更改密码的临时页面。我知道如何更改密码脚本,但如何创建指向临时页面的链接?
忘记了.php
echo "<div id='sign-parent-container'>
<div class='form-title'>Forgotten Username/Password</div>
<form action='/login' action='post' id='forgot-form'>
<ul>
<li>Type the email address you registered with, a link to a temporary page where you can change your password will be sent.</li>
<li>
<ul>
<li><input type='text' name='email' value='Type Registered Email Here' class='signupfield-2' /><li>
<li style='display:none;'><span class='error'>This email doesn't exist</span></li>
</ul>
</li>
<li class='form-submit' data-type='forgot'><a>Request Password Change</a>
<input type='hidden' name='forgot' value='1' /></li>
</ul>
</form>
</div>";
/电子邮件
$to = $email;
$subject = "example - New Password Request.";
$headers = "From: example.com";
$server = "http://www.example.com";
ini_set("SMTP",$server);
$body="
Hello $username,\r\r
Your login details are below;\r\r
Click the link below to change password:\r
http://www.exmaple.com/temporarylink
\n\n
";
//function to send email
mail($to, $subject, $body, $headers);