提交表单时,我收到空白电子邮件或没有内容的电子邮件。
谢谢您的帮助。
我尝试了几次更改并多次更改了代码,但是找不到解决方法。
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: Rafael';
$to = 'Do-Not-Reply@bestcheapaffordablewebhosting.com';
$subject = 'Support Message';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
?>
<?php
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Thank you! Your message has been sent. We will get back to you
as soon as possible!</p>';
} else {
echo '<p>We are sorry, but something went wrong, go back and try
again!</p>';
}
$email_from = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
if ($email_from === false) {
echo 'error, invalid email';
}
}
?>
<form method="post" action="shared-website-hosting.php" class="bg-white
rounded pb_form_v1">
<h2 class="mb-4 mt-0 text-center">Contact Us</h2>
<div class="form-group">
<input name="name" class="form-control pb_height-50 reverse"
placeholder="Name">
</div>
<div class="form-group">
<input type="email" class="form-control pb_height-50 reverse"
name="email" placeholder="Email">
</div>
<div class="form-group">
<textarea name="message" class="form-control pb_height-50
reverse" placeholder="Message"></textarea>
</div>
<div class="form-group">
<input id="submit" name="submit" type="submit" value="Submit"
class="btn btn-primary btn-lg btn-block pb_btn-pill btn-shadow-blue">
</div>
</form>
我希望此联系表有效。谢谢您的帮助。