我最近上传了我的网站,但无法正常使用我的表格。有人可以帮我吗。在我收到HTTP 500错误之前,我意识到我的代码中有一个类型,但是自从我修复它以来,我没有任何错误,但是在提交表单时,我也没有收到任何电子邮件。有人可以让我知道我做错了吗?!
<?php
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$mailFrom = $_POST['mail'];
$message = $_POST['message'];
$mailTo = "info@orbitwebdesign.ca";
$headers = "From: ".$mailFrom;
$txt = "You have recieved an e-mail from ".$name.".\n\n".$message;
mail($mailTo, $subject, $txt, $headers);
header("Location: contact.php?mailsend");
}
?>
<section class="section-form" id="contact">
<div class="row">
<h2>BOOK A FREE CONSULTATION!</h2>
</div>
<div class="row">
<form method="POST" action="contact.php" class="contact-form">
<div class="row">
<div class="col span-1-of-3">
<label for="name">Name</label>
</div>
<div class="col span-2-of-3">
<input type="text" name="name" id="name" placeholder="Your name" required>
</div>
</div>
<div class="row">
<div class="col span-1-of-3">
<label for="mail">Email</label>
</div>
<div class="col span-2-of-3">
<input type="email" name="email" id="email" placeholder="Your email" required>
</div>
</div>
<div class="row">
<div class="col span-1-of-3">
<label>Message</label>
</div>
<div class="col span-2-of-3">
<textarea name="message" placeholder="Your message"></textarea>
</div>
</div>
<div class="row">
<div class="col span-1-of-3">
<label> </label>
</div>
<div class="col span-2-of-3">
<input class="input-btn" name="submit" type="submit" value="Send">
</div>
</div>
</form>
</div>
</section>
答案 0 :(得分:1)
电子邮件地址存储在$_POST['email']
中。
但是,在您的contact.php中,第5行:
$mailFrom = $_POST['mail'];
尝试将$_POST['mail']
替换为$_POST['email']
希望有帮助。
ps 同样,您的html代码中的标签也用于“ 邮件”,而不是用于“ 电子邮件”,例如输入标签
答案 1 :(得分:-1)