您好我有一个非常简单的html / PHP电子邮件表单,它工作正常,直到我将复选框添加到我的表单并尝试让他们提交所有其他信息。现在它根本没有向该地址发送电子邮件。我做的另一个改变是,而不是我的html动作是action =“mail.php”我改为链接到感谢页面,所以action =“thankyou.html”。这会弄乱什么吗?我对PHP不是很好,所以如果有人能给出建议,我将不胜感激,谢谢你提前
HTML
<form action="mail.php" method="POST">
<p>Name</p>
<input type="text" name="name">
<p>Email</p>
<input type="text" name="email">
<p>Phone Type: Apple/Android/other</p>
<input type="text" name="phone">
<p>Interested in BETA testing?<br><span style="font-size:9pt; font-weight: 300;">(Win prizes! Have fun! Be invited to excluseive Dapp parties! It's super easy and you can opt out at any time)</span></p>
<div class="checkbox">
<input type="checkbox" name="check[]" value="YES" checked>
<label for="option1">Yes</label>
<input type="checkbox" name="check[]" value="NO">
<label for="option2">No</label>
</div>
<button type="submit" name="submit" value="submit" style="margin-top:15px">Dapp us up!</button>
</form>
PHP
<?php
if(isset($_POST['submit']))
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
foreach($_POST['check'] as $value) {
$check_msg .= "Checked: $value\n";
}
$body = "From: $email\n Phone: $phone\n BETA:\n $value\n $check_msg";
$to = "dappusup@gmail.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $mailheader)) {
echo 'Your message has been sent!';
}
}
header("Location: thankyou.html");
exit();
?>