0
The deal is that I created a form a few days ago and it worked fine, but I went to test it today and it receives the blank data.
Could you help me, please?
<?php var_export($_POST); exit;
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$message = $_POST['message'];
$email_from = $_POST['email'];
$email_subject = "New Form Submission";
$email_body = "Nome: $name.\n".
"Email: $visitor_email.\n".
"Menssagem: $message.\n";
$to = "[email protected]";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
mail($to,$email_subject,$email_body,$headers);
header("Location: contato.php")
?>
<div class="contact-form">
<form id="contact-form" method="post" action="contact-form-handler.php">
<input name="name" type="text" class="form-control" placeholder="Seu nome" required> <br>
<input name="email" type="email" class="form-control" placeholder="Seu email" required><br>
<textarea name="message" class="form-control" placeholder="Mensagem" row="4" required></textarea>
<input type="submit" class="form-control submit" value="Enviar mensagem">
</form>
</div>
Then the email arrives, but without content?
– Woss
That, the ''name, email and 'message' fields all come blank, only with a dot . at the end
– Jonatas Galvão
Put a
var_export($_POST); exit;
in the first line ofcontact-form-handler.php
, fill in the form and tell us what appeared on the screen. You can [Edit] the question and add the result directly to it.– Woss
still remains the error and the page that appears now in the url is contact-form-Handler.php blank
– Jonatas Galvão
Error? What mistake? There was no error in the story to keep appearing.
– Woss
The error I say is that the email is received blank
– Jonatas Galvão
But I shouldn’t have sent the e-mail; there is one
exit
there for the execution. Are you sure you put the code I quoted in the first line? Obviously it needs to be inside the PHP tags, not as you put it in the question.– Woss
I put the code you recommended before <?php, keep receiving the blank email and the following message appears now: var_export($_POST); Exit; Warning: Cannot Modify header information - headers already sent by (output Started at /home/eminente/public_html/contact-form-Handler.php:2) in /home/eminente/public_html/contact-form-Handler.php on line 24
– Jonatas Galvão
Need to put inside the tag:
<?php var_export($_POST); exit; ...
– Woss
right, now it appears array ( ) and the email has not arrived
– Jonatas Galvão
Which shows that your HTML is not sending the information because your
$_POST
is coming empty.– Woss
what should I do?
– Jonatas Galvão
comment the Exit putting two bars in front of it and you will receive the email with the data.
var_export($_POST); //exit;
– user60252