我正在为我的网站制作一个联系表单,该表单使用 php 将输入的信息发送到我的电子邮件。
我的问题是 isset php 函数返回 false。我不知道这是为什么。
这是我的php代码(输出结果是“未发送”)
<?php
if (isset($_POST['submit'])){
$name = $_POST['name'];
$subject = $_POST['subject'];
$mailFrom = $_POST['mail'];
$message = $_POST['message'];
$mailTo = "btrorapps@gmail.com";
$headers = "From: " .$mailFrom;
$txt = "You have received an email from " .$name.".\n\n".$message;
if (mail($mailTo, $subject, $txt, $headers)){
echo "<h1>sent successfully</h1>";
} else {
echo "<h1>something went wrong</h1>";
}
} else {
echo "not sent";
}
?>
这是我的表单代码
<form action="contactform.php" method="post" enctype="text/plain">
<label for="name">Name</label>
<input type="text" name="name" placeholder="Full name.." maxlength="20" required>
<label for="mail">Email</label>
<input type="text" name="mail" placeholder="Your email.."
pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z{2,}$" required>
<label for="subject">Subject</label>
<input type="text" name="subject" maxlength="25" placeholder="Subject..">
<label for="message">Message</label>
<input type="text" name="message" placeholder="Message.." style="height:170px"
maxlength="150" required>
<input type="submit" value="submit" name="submit">
</form>
慕的地10843
浮云间