我有这个php形式:
<form method="post" action="mailer.php" class="contact-form-map">
<div class="row">
<input type="text" name="name" id="name" placeholder="Your Name" required>
</div>
<div class="row">
<input type="number" name="number" id="number" placeholder="Contact Number" required>
</div>
<div class="row">
<textarea type="text" name="message" id="message" placeholder="Message" rows="6" cols="33" required></textarea>
</div>
<div class="row">
<input type="submit" class="map-button" value="Send">
</div>
</form>
这是我的mailer.php
<?php
if(isset($_POST['submit'])){
$to = "lala.lal@gmail.com"; // info@computerrepairscroydon.co.uk
$name = $_POST['name'];
$number = $_POST['number'];
$subject = "Form submission - Contact";
$message = $name . " " . " wrote the following:" . "\n\n" . $_POST['message'] . "\n\n" . " Contact number: " . $number ;
$headers = "From:" . $name;
mail($to,$subject,$message,$headers);
echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";
header("Location: index.html?success=1#form");
}
?>
当我输入信息到de form并点击发送没有任何反应,但电子邮件没有发送,我不在我的Gmail上。 那是为什么?
答案 0 :(得分:2)
您忘记将name =“submit”写入提交输入
<input type="submit" class="map-button" value="Send" name="submit">
这就是为什么代码“跳”到if isset $ _POST [“submit”]
答案 1 :(得分:0)
您需要在提交按钮中添加name =“submit”。
<input type="submit" class="map-button" value="Send" name="submit">