0
I have a form for sending emails and although it is working - when sending the message - it presents a problem where when receiving these messages in the recipient’s email, it comes duplicated.
One message arrives normal with all fields filled and the other comes with empty fields.
Can you help me in what may be happening?
The code is this below:
<?php
ini_set("SMTP", "localhost");
$nome = $_POST['nome'];
$email = $_POST['email'];
$telefone = $_POST['telefone'];
$mensagem = $_POST['mensagem'];
$dpto = "[email protected]";
$Titulo = "MENSAGEM ENVIADA PELO FORMULÁRIO DO SITE";
$Destinatario = "$dpto";
$mensagem1 = "
Nome: $nome
E-mail: $email
Telefone: $telefone
$mensagem";
mail("$Destinatario","$Titulo","$mensagem1","From:$email");
?>
How are you calling this code? is using ajax? or a simple form?
– Wictor Chaves
Hi Wictor. I am using a simple form: <form action="<? $PHP_SELF; ? >" method="POST">
– Fernanda
PHP itself is working correctly, I did a test here and received the mail straight.
– user60252
Truth Leo ... is right. I just don’t understand why I get the duplicate message
– Fernanda
so it’s nothing with PHP, I didn’t get duplicate
– user60252
Try replacing $PHP_SELF with $_SERVER["PHP_SELF"]
– Wictor Chaves
I will then see outside of PHP what it can be. Thank you very much Leo for taking the test and for your return !!
– Fernanda
Obrigado Wictor !!
– Fernanda
even though this variable $PHP_SELF has not been declared, the code works the same way
– user60252
Yes you can @Leocaracciolo. Later I will see better what may have been and leave reply here from the solution. Thanks again !!
– Fernanda
Fernanda, what form of verification do you use to enter this sending code? (e.g..,
isset
to see if the variables coming from the form have data).– Sam