dsw8292301 2019-06-20 07:40
浏览 62

在PHP中联系表单发送空白电子邮件

I am getting blank emails or emails with no content when the form is submitted.

Thank you for your help.

I tried several changes and changed the code several times, but I cannot find the solution.

<?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
 E-Mail: $email
 Message:
 $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>

I would like this contact form to work. Thank you for your help.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 孟德尔随机化结果不一致
    • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了
    • ¥50 切换TabTip键盘的输入法