我有一个使用php构建的contactform。
我的域名是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")
}
非常感谢您的帮助。
答案 0 :(得分:0)
代码中有一些语法错误。
=
丢失,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");
}