【发布时间】:2020-09-05 15:43:15
【问题描述】:
我已经尝试了this tutorial 中列出的所有内容。
但无论如何,当复选框脚本仍然产生错误消息时。
<?php
ini_set( display_errors, 1 );
error_reporting( E_ALL );
$email = $_POST['myEmail'];
$name = $_POST['myName'];
if (isset($_POST['news'])) {
$checkBoxValue = "yes";
} else {
$checkBoxValue = "no";
}
$to = "web@myemail.com";
$subject = "Add me to the Launch Day Notification List!";
$headers = "From:".$email;
$txt = "This person wishes to be added to the launch day notification list: $name\nDoes
this person wish to subscribe to the newsletter? $news";
mail($to,$subject,$headers,$txt);
echo "Thank you for your inquiry, you will be added to our launch day notification
list!";
?>
客户端代码:
<form action="mail.php" method="post">
Name: <input type="text" name="myName" class="contactform" placeholder="name"required><br>
Email: <input type="text" name="myEmail" class="contactform" placeholder="you@youremail.com" required>
<p>Would you like to subscribe to our newsletter?</p>
<be>
<input type="checkbox" name="news" value="Yes" checked>
<label for="news">Yes, I would like to subscribe</label><br>
<input class="btns" name="btn-send" id="mySubmit" type="submit" value="submit">
<input class="btns" name="btn-reset" id="myReset" type="reset" value="reset">
</form>
【问题讨论】:
-
您也可以发布您的客户端代码吗?没有足够的信息来明确说明问题所在。
-
如果您收到
error message,那么您应该向我们展示错误消息 -
@Ynhockey 发布
-
良好的代码缩进将帮助我们阅读代码,更重要的是它将帮助您调试您的代码Take a quick look at a coding standard为您自己的利益。您可能会被要求在几周/几个月内修改此代码,最后您会感谢我的。