-1
I made a simple system to recover password. The system is working normally, but when the user clicks on the confirmation email, his email appears in the URI, what do I do? Here’s the code:
This is the html form:
<section class="recipiente margem-topo-100">
<form action="recuperar_por_email.php" method="post" class="coluna">
<input type="text" name="recuperar-senha" placeholder="Insira seu email">
<button class="icones icone-enviar"></button>
</form>
</section>
This is the code that sends the email and creates the variables I use:
<?php
require_once "PHPMailer/PHPMailerAutoLoad.php";
require_once "interno/conecta.php";
require_once "interno/funcoes.php";
$recupera = $_POST['recuperar-senha'];
$link = "http://localhost/toqve/recuperar.php?recupera=".$recupera;
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->isHTML(true);
$mail->CharSet = 'utf-8';
$mail->Host = 'mx1.weblink.com.br';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = '*********';
$mail->setFrom("[email protected]", "daLvz");
$mail->FromName = 'daLvz';
$mail->Subject = "Recuperar senha";
$mensagem = "Clique <a href=".$link.">aqui</a> para recuperar sua senha.
$mail->Body = $mensagem;
$mail->AltBody = "Conteudo do email em texto";
$mail->addAddress($recupera);
if($mail->Send()) {
header("Location: confirmacao.php");
} else {
echo "Erro ao enviar email". $mail->ErrorInfo;
}
This is the page that appears when the user clicks on the received email:
<?php
require_once "cabecalho.php";
require_once "interno/conecta.php";
require_once "interno/funcoes.php";
$recupera = $_GET['recupera'];
?>
<section class="recipiente margem-topo-100">
<form class="coluna" action="sucesso.php" method="post" >
<input type="text" name="recupera" value="<?=$recupera?>">
<input type="password" name="senha" placeholder="insira uma nova senha">
<button class="icones icone-enviar"></button>
</form>
</section>
Can anyone help me? Thank you!
There are some missing
"
as you can see by the Highlight of the code. Confirm if you have so in your code or if it was so only in the question– Isac
I don’t see where it’s missing, but I assure you my code is working. The only problem is that the user’s email is coming in the URI after the user clicks on the link that goes to it by email. This is what I need to change. But thanks for the @Isac remark
– Francis Vagner da Luz
See this part of the code:
$mensagem = "Clique <a href=".$link.">aqui</a> para recuperar sua senha. 

 $mail->Body = $mensagem;
. Note how the$mensagem
doesn’t have the"
closing– Isac
Yes, true, but it was at the time that I was adapting the question here for the forum. Here I am closing.. It’s just that I forgot to put
– Francis Vagner da Luz
Not related to doubt, but extremely relevant: passwords should not be recoverable. What is usually done is to provide a link for the user to create a new password based on a token. If your password is recoverable by a user, it is vulnerable to attacks in case of data theft, a classic security breach. With few exceptions (and your situation does not seem to be one of them) passwords must be stored irreversibly. Here are some concepts about safe password storage
– Bacco