我有一个联系人表单是用php建立的。
我的域名是bestsellerprime.com
脚本执行后,假设发送任何电子邮件到info@bestsellerprime.com,页面应该重新路由回主页(index.html),但我收到任何错误。错误信息为:
“此页不工作bestsellerprime.com当前无法处理此请求。HTTP错误500”
我该如何解决这个问题,代码如下:
<div class="form">
<form id="email-form" name="email-form" data-name="Email Form" class="form" method="post" action="contactform.php"><label for="name">Name:</label><input type="text" class="input" maxlength="256" name="name" data-name="Name" placeholder="Enter your name" id="name"><label for="email-3">Email Address:</label><input type="email" class="input" maxlength="256" name="email" data-name="email" placeholder="Enter your email" id="email-3" required=""><label for="question">Question:</label><input type="text" class="input" maxlength="256" name="question" data-name="question" placeholder="Enter your question" id="question" required=""><input type="submit" value="Submit" data-wait="Please wait..." class="contact-submit-button button" name="submit"></form>
<div class="form-done">
<div>Thank you! Your submission has been received!</div>
</div>
<div class="form-fail">
<div>Oops! Something went wrong while submitting the form.</div>
</div>
</div>PHP:
<?php
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$mailFrom = $_POST['email'];
$question = $_POST['question'];
$mailTo = "info@bestsellerprime.com";
$headers "From: ".mailFrom;
$txt = "You have received an e-mail from ".$name.".\n\n".$message;
mail($mailTo, $mailFrom, $txt, $headers);
header("Location: index.html")
}任何帮助都是非常感谢的。
发布于 2018-07-26 18:03:50
代码中有一些语法错误。
以下行中缺少=且mailFrom应为$mailFrom:
$headers "From: ".mailFrom;该行末尾缺少分号:
header("Location: index.html")正确的代码:
<?php
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$mailFrom = $_POST['email'];
$question = $_POST['question'];
$mailTo = "info@bestsellerprime.com";
$headers = "From: " . $mailFrom;
$txt = "You have received an e-mail from " . $name . ".\n\n" . $message;
mail($mailTo, $mailFrom, $txt, $headers);
header("Location: index.html");
}https://stackoverflow.com/questions/51536164
复制相似问题