I have faced a curious problem. I made a basic form in php
just to send email through the site. But I'm running some tests on the hosting service and I've received several phantom emails before the test email.
I've already checked to see if something is wrong with the code, but I believe that as basic as it may be, it's okay. Can someone give me a light?
<?php
$msg=0;
@$msg= $_POST['msg'];?>
'<section class="form">
<?php if($msg=="enviado"): ?>
<h3>Mensagem enviada. Agradecemos seu contato!</h3>
<?php else: ?>
<form class="contact-form" action="contactForm.php" method="post">
<input type="text" id="name" name="name" placeholder="Nome completo">
<input type="text" id="mail" name="mail" placeholder="E-mail">
<input type="text" id="telephone" name="telephone" placeholder="Telefone">
<input type="text" id="company" name="company" placeholder="Sua empresa">
<input type="text" id="subject" name="subject" placeholder="Assunto">
<textarea id="message" name="message" placeholder="Deixe aqui sua mensagem!"></textarea>
<button class="btn btn-success" type="submit" name="submit">Enviar</button>
</form>
<?php endif; ?>
</section>'
<?php
$para= "[email protected]";
$assunto="Contato pelo Site.";
$name= $_POST['name'];
$mail= $_POST['mail'];
$telephone= $_POST['telephone'];
$company= $_POST['company'];
$subject= $_POST['subject'];
$msg= $_POST['message'];
$corpo= "<strong>Mensagem de contato!</strong><br><br>";
$corpo .= "<strong>Nome: </strong> $name<br><br>";
$corpo .= "<strong>E-mail: </strong> $mail<br><br>";
$corpo .= "<strong>Telefone: </strong> $telephone<br><br>";
$corpo .= "<strong>Empresa: </strong> $company<br><br>";
$corpo .= "<strong>Assunto: </strong> $subject<br><br>";
$corpo .= "<strong>Mensagem: </strong> $msg";
$header="Content-Type: text/html; charset= utf-8\n";
$header .="From: $mail Reply-to: $mail\n";
mail($para,$assunto,$corpo,$header);
header("location:index.php?msg=enviado");?>