联系人表单脚本未运行,白页



尝试提交包含以下条目的联系表单时出现白屏:-名字-电子邮件-主题-消息

我试图通过我的网站接收电子邮件。我检查了所有变量名称等,似乎一切都是正确的。我是PHP的新手,所以我对下一步要尝试什么有点模糊。谢谢

<form method"POST" action="action/form-submit.php"> <!--NO FOR ATTRIBUTE, NOT ADDING FUNCTIONALITY-->
                <h2>Contact Me:</h2>
                  <label>Your Name:</label>
                    <input name="name" type="text" placeholder="Your Name..." required/>
                  <label>Email:</label>
                    <input name="email" type="email" placeholder="Email..." required/>
                  <label>Query Type:</label>
                    <select id="qry" name="query" required>
                      <option value="" disabled selected>Please Select:</option>
                      <option value="jobs">Jobs</option>
                      <option value="website">Website Issues</option>
                      <option value="info">Information</option>
                    </select>
                  <label>Your Message:</label>
                  <textarea name="info" placeholder="Your Message..." required></textarea>
                  <input type="submit" value="Submit">
              </form>

然后是PHP代码:

<?php
  $vname = $_POST['name'];
  $vemail = $_POST['email'];
  $vquery = $_POST['query'];
  $vmessage = $_POST['info'];
  $email_from = "test@gmail.com";
  $email_subject = "New Website Submission";
  $email_body = "Visitor Name: $vname.n".
                  "Visitor Email: $vemail.n".
                    "Visitor Subject: $vquery.n".
                      "Visitor Message: $vmessage.n";
  $to = "bradleyarcher98@gmail.com";
  $headers = "From: $email_from rn";
  $headers .= "Reply-To: $vemail rn";
  mail($to,$email_subject,$email_body,$headers);
  header("location: contact.html");
?>

为了查看出了什么问题,您需要打开 PHP 错误处理。

启用此功能后,您将不再只看到一个白页,还会向浏览器发送一条带有文件名、行号和描述错误的错误消息。

<?php
session_start();
$vname = $_POST['name'];
$vemail = $_POST['email'];
$vquery = $_POST['query'];
$vmessage = $_POST['info'];
$subject = " YOUR MESSAGE Title ";
$headers = "MIME-Version: 1.0" . "rn";
$headers .= "Content-type:text/html;charset=UTF-8" . "rn";
$headers .= "From: "YOUR SITE NAME" . "rn";
$message = "
<!-- you can add CSS Aswell -->
<div>
<p>Visitor Name: ".$_POST['name']."<p>
<p>Visitor Email: ".$vemail."<p>
<p>Subject: ".$vquery."<p>
<p>Message :".$vmessage."<p>
</div>
";
mail($to,$subject,$message,$headers);
?>

相关内容

  • 没有找到相关文章

最新更新