2
I’ve been looking for this problem here on the forum, but I haven’t found it. If there is a link and someone can send me I’m grateful. The problem is this:
This form of mine sends 2 emails to the recipient I set up. I looked at the code again and again, but I didn’t understand why.
PHP
$nome = $_POST['nome'];
$texto = $_POST['texto'];
$enviar= $_POST['enviar'];
if(isset($enviar)){
$corpoMSG = "Oi, meu nome é: ".$nome."<br /><br />".$texto;
$assunto = "Teste para envio de email";
require_once('phpmailer/class.phpmailer.php');
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->SetFrom('[email protected]', 'Orçamento');
$address = "[email protected]";
$mail->AddAddress($address, "destinatario");
$mail->Subject = $assunto;
$mail->MsgHTML($corpoMSG);
if(!$mail->Send()) {
echo "<div class='alert alert-danger'><p style='padding: 0; margin: 0;'>Email não enviado.</p></div>";
} else {
echo "<div class='alert alert-success'><p style='padding: 0; margin: 0;'>
Email enviado com sucesso!</p></div>"; }}
is making two requisitions ?
– Gabriel Rodrigues
how do I verify this?
– Diego Souza
go in your browser, right click, inspect element and console.
– Gabriel Rodrigues
Is that all the code of the file? doesn’t seem to have any problems, check if there are any
cc
lost or of aecho
at all addresses(to
,cc
andcco
)– rray
It is. html is just a form with two text inputs and the upload button.
– Diego Souza
Gabriel, here in the console nothing appears. In case I always use it for js. How do I use it for php?
– Diego Souza
Press F12 on Chrome, go to the "Network" tab, there it shows all the pages that are accessed. See if that page that sends is not called 2 times.
– GilCarvalhoDev
um... very interesting... In this tab appeared 2 times the page that sends the form. One with the post method (the one I’m using in the form) and the "Document" type. The other uses the get method and the "text/html type"
– Diego Souza