繁体   English   中英

PHP电子邮件处理程序无法发布

[英]PHP email handler cannot POST

我目前正在使用联系表单,该表单将允许用户提交将邮件重新路由到联系电子邮件的消息(一般的基本php电子邮件处理程序。我目前正在使用Brackets实时预览来查看和编辑此消息,但不确定是否与我遇到的问题有关

HTML

<form action="mail_handler.php" method="post">
    <div class="w3-row-padding" style="margin:0 -16px 8px -16px">
      <div class="w3-half">
        <input class="w3-input w3-border" type="text" placeholder="Name" required name="name">
      </div>
      <div class="w3-half">
        <input class="w3-input w3-border" type="email" placeholder="Email" required name="email">
      </div>
    </div>
    <input class="w3-input w3-border" type="text" placeholder="Message" required name="message">
    <button class="w3-button w3-black w3-right w3-section" type="submit">
      <i class="fa fa-paper-plane"></i> SEND MESSAGE
    </button>
  </form>

PHP

<?php 
if(isset($_POST['submit'])){
$to = "email@email.com"; 
$from = $_POST['email']; 
$name = $_POST['name'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $name . " wrote the following:" . "\n\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . $name . "\n\n" . $_POST['message'];

$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
header('Location: email_confirm.html');
exit();
}

?>

同样,我不确定这是否只是括号问题或代码错误。 我将不胜感激一些反馈。 谢谢!

编辑:这不是变量的问题,请不要将其标记为缺少变量的重复项。 此问题已解决,不是解决方案。

在您的HTML中更改

<button class="w3-button w3-black w3-right w3-section" type="submit">

<input class="w3-button w3-black w3-right w3-section" type="submit" value="Submit" name="submit">

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM