Allow user to change password
I have routines to register a new user who can update data files displayed on the website and to long them in to access update routines. I now need to write a routine which allows a user to change his password. I've asked for the email account and then sent a message to the account containing a link to an update routine, but the email is unauthenticated and contains a "noname" document containing the message, which is
Click on the link to reset your password.
https://www.domain.com/reset.php
This is useless. When I follow routines to reset a password, the link is never this legible - it's always long in indeciperable. How do you do that? And what am I doing wrong?
My code:
if (!$suspect && !$errors) {
// send email with link to reset routine
$to = $email;
$subject = 'Change password';
$headers = "Content-Type: text/plain, charset=utf-8\r\n";
$headers .= "From: webmaster@domain.com";
$param = '-fwebmaster@domain.com';
$message = "Click on link to change your password.\r\n\r\n".'https://www.support.domain.com/reset.php';
$mailSent = mail($to, $subject, $message, $headers,$param);
if (!$mailSent) {
$errors[] = "Your mail could not be sent.<br>";
} else {
echo 'Mail sent OK<br>';
}
