不能发布contactform.php

时间:2019-02-03 02:14:21

标签: php html

我不熟悉php。我搜索了与找不到解决方案类似的问题。我遵循了一个相当简单的教程,将发送电子邮件功能添加到Web应用程序,但是由于在测试将电子邮件发送到yahoo时收到此错误,因此我无法使其正常工作。我想寻求解决方案的帮助,或者如何使这段代码更好。预先感谢

这是我的错误
不能POST /contactform.php

这是我index.html中的表单代码

<form action="contactform.php" method="post">
                <div class="form-group">
                  <input type="text" name="name" placeholder="Full Name" class="form-control" id="name">
                </div>

                <div class="form-group">
                  <input type="text" name="email" placeholder="Email" class="form-control" id="email">
                </div>

                <div class="form-group">
                  <input type="text" name="subject" placeholder="Subject" class="form-control" id="message-text"></input>
                </div>

                <div class="form-group">
                  <textarea name="message" placeholder="Message" class="form-control" id="message-text"></textarea>
                </div>
                <button type="submit" name="submit" class="btn btn-outline-dark">Send message</button>
              </form>

这是我的contactform.php即在同一文件夹作为我的index.html

<?php
  if (isset($_POST['submit'])){

    $name = $_POST['name'];
    $mailfrom = $_POST['email'];
    $subject = $_POST['subject'];
    $message = $_POST['message'];

    $mailTo =  "myemail@yahoo.com";
    $headers = "From: ".$mailfrom;
    $txt = "You have received an email from ".$name.".\n\n".$message;

    mail($mailTo, $subject, $txt, $headers);
    header("Location: index.html?mailsend");
    }

?>

0 个答案:

没有答案