Here's my contact form php code. Every morning I receive a blank response from my contact form.
<?php
$to = "test@youremail.com";
$subject = "Contact Form Inquiry";
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$message = $_POST['message'] ;
$content = "From: $name \n Message: $message";
$headers = "From: $email ";
$sent = mail($to, $subject, $content, $headers) ;
if($sent)
{
print "Your mail was sent successfully";
}
else
{
print "We encountered an error sending your mail";
}
?>
Why do I receive this response?
$_POST['message'] ;
Please check if this variable coming up with any value from your form.
Use a CAPTCHA or similar alternatives, there are a lot of bots out there. You could also generate a CSRF token (look at the Wikipedia article if you aren't sure about it), so the form will require it before actually sending the e-mail. Many frameworks do this for you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.