【发布时间】:2020-02-20 23:18:57
【问题描述】:
我不太了解 PHP,但我使用了一个教程将我的联系表连接到我的电子邮件。下面是我的 html 联系表,以及我写的 PHP 文件:
<form name="contactform" method="post" action="mail.php">
<label for="fname">Name</label>
<input type="text" id="fname" name="name" placeholder="Your name..">
<label for="email">Email</label>
<input type="text" id="email" name="email" placeholder="Your email address">
<label for="city">City</label>
<input type="text" id="city" name="city" placeholder="Your city">
<label for="message">Message</label>
<textarea id="message" name="message" placeholder="Write something.." style="height:170px">
</textarea>
<input type="submit" value="Submit" name="submit">
</form>
<?php
if (isset($_POST['submit'])){
$name = $_POST['name'];
$mailFrom= $_POST['email'];
$city = $_POST['city'];
$message = $_POST['message'];
$mailTo = "(insert my email here)";
$headers = "From: ".$mailFrom;
$txt = "You received an e-mail from ".$name.".\n\n"
mail($mailTo, $txt, $headers);
header("Location: " contact.html?mailsend");
}
?>
【问题讨论】:
-
在您的 PHP 中看起来像一个解析错误。
header("Location: " contact.html?mailsend");1中间多了一个引号