Php - Send Login and Password to User

Asked

Viewed 92 times

0

I would appreciate your help. The system I am creating randomly registers a password using Hash and I use the email as login. This data is in the comic book. Now I need to send an email to the user informing this data so that he can enter the system.

I’m trying to do this using the file that receives the data from the registration screen but I’m not succeeding as I could do to get it fixed?

Follow the add-couple file

<?php require_once ("conecta.php");?>
<?php require_once ("noivosDAO.php");?>
<?php require_once ("noivos.php");?>

<?php
$noivo = new Noivo();
$noivo->setNome1($_POST["nome1"]) ;
$noivo->setSobrenome1($_POST["sobrenome1"]);
$noivo->setEmail($_POST["email"]);
$noivo->setNome2($_POST["nome2"]);
$noivo->setSobrenome2($_POST["sobrenome2"]);
$noivo->setTelefone($_POST["telefone"]);
$noivo->setRua($_POST["rua"]);
$noivo->setNumero($_POST["numero"]);
$noivo->setCep($_POST["cep"]);
$noivo->setCidade($_POST["cidade"]);
$noivo->setSenha();
$nome_imagem = $noivo->setFoto( $_FILES["foto"]);

$dao = new noivosDAO($conexao);
if ($dao->insereNoivos($noivo, $nome_imagem, $email, $senha)) {
 // Mail it
$email = $_POST["email"];
$senha = $_POST["senha"];
require_once("PHPMailerAutoload.php");
require_once("class.phpmailer.php");

$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = 'smtp.xxxxxxxxxxxx.com.br';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "[email protected]";
$mail->Password = "xxxxxxxxx";
$mail->setFrom("[email protected]", "xxxxxxxxxxxxxx");
$mail->addAddress($email);
$mail->Subject = "Contato site xxxxxxxxxxxxx";
$mail->MsgHTML($body);
$body = "<html>
 <head>
  <title>Registro xxxxxxxxxxxxxxxxxxxxx</title>
</head>
<body>
 <p>Obrigado por se registrar em nosso site, segue abaixo seu login e senha 
 para acesso:</p>
 <table>
<tr>
 <p> Login: {$email}</p>
</tr>
<tr>
  <p> Senha: {$senha}</p>
</tr>
<tr>
  <p>Link para acesso: <a href 'https://xxxxxxxxxxxxxxxxx/login.php'</a></p>
</tr>
  </table>
 </body>
 </html>"
 ;
if($mail->Send())
    $msg = "<center><h1>Dados enviados com sucesso.</h1>
            Você receberá um e-mail para confirmar seu cadastro.<br/>
            Confirme seu cadastro para receber nossas mensagens.<br/><br/>
            Obrigado.</center>";
else
    $msg = "<center><h1>Dados não enviados</h1>
            Por favor, tente novamente.</center>";
?>
<div>
<?php
    if(isset($msg))
    echo "$msg";
?>
</div>
<?php
var_dump($mail); exit;
 ?>
  • Which error is returning ?

1 answer

0


Phpmailer throws exceptions. So you can get a more specific error with the error that is happening.

$mail = new PHPMailer();
try {
  // ...
  $mail->Send();
} catch (phpmailerException $e) {
  echo $e->errorMessage(); // Mensagens de erro lançadas pelo PHPMailer
} catch (Exception $e) {
  echo $e->getMessage(); // Outros erros que possam ter acontecido
}
  • Thank you Foxtrot follow exceptions: Notice: Undefined variable: email in C: Bitnami wampstack-5.6.19-0 apache2 htdocs wedding add-couple.php on line 21 Notice: Undefined variable: password in C: Bitnami wampstack-5.6.19-0 apache2 htdocs wedding add-oncouple.php on line 21Notice: Undefined index: urlSite in C: Bitnami wampstack-5.6.19-0 apache2 htdocs wedding adds couple.php on line 23 Notice: Undefined variable: body in C: Bitnami wampstack-5.6.19-0 apache2 htdocs wedding adds-Couple.php on line 48Signated Dates Please try again.

  • Foxtrot, I changed some fields and the exceptions look like this:Notice: Undefined variable: email in C: Bitnami wampstack-5.6.19-0 apache2 htdocs wedding add-couple.php on line 21 Notice: Fineunded variable: password in C: Bitnami wampstack-stack5.6.19-0 apache2 htdocs wedding add-couple.php on line 21 Warning: stream_socket_enable_crypto(): Peer=*.uni5.net' did not match expected CN=smtp.xxxxxxxxxxx' in C: Bitnami wampstack-5.6.19-0 apache2 htdocs wedding class.smtp.php on line 344

  • I believe I’m not able to bring the email and password data from the database.

  • Yeah, and you got the body set $mail->MsgHTML($body); before its definition.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.