1
I created a form so that users could contact me through the site, however, when the form data is filled and sent, the email arrives blank and an email called postmaster. Despite my attempts to change variables and the like, the information that people fill, never appear, just the same blank email with a short sentence that I put to know from whom the email came.
Excerpt from the HTML where I start the form.
<section class="section section-icons grey lighten-4 center">
<div class="col s12 m6">
<div class="card-panel white -3">
<i class="material-icons medium blue-text">mail</i>
<h4>Preencha os campos abaixo para entrar em contato conosco</h4>
<form class="contact-form" action="form.php" method="post">
<input type="text" name="name" placeholder="Nome">
<input type="email" name="mail" placeholder="E-mail">
<input type="text" name="subject" placeholder="Assunto">
<input textarea name="message" placeholder="Mensagem"></textarea>
<button type="submit" name="submit" class="btn-large blue darken-3">Enviar</button>
</form>
</div>
</div>
<div class="row">
<div class="col s12 center">
<a href="#top" class="btn btn-small blue darken-3">
<i class="material-icons left">arrow_upward</i> Retornar ao topo
</a>
</div>
</div>
</div>
</section>
PHP I’ve been trying to use:
<?php
if(isset($_POST['submit'])){
$name = $_POST['name'];
$mailFrom = $_POST['mail'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$mailTo = "[email protected]";
$headers = "From: ".$mailFrom;
$txt = "Foi recebida uma nova mensagem de:"$name.".\n\n".$message;
mail($mailTo, $subject, $txt, $headers);
header("Location: index.html?emailenviado");
}
?>