[英]PHP emailer to provide answer to checkbox
昨天为邮递员提供了一些php代码,获得了很大的帮助,但忘记了我也需要知道如何包括该代码,以便邮递员知道在复选框中选中了哪个选项。 这是一个简单的“加入邮件列表”选项,只有“是”或“否”选项可用。
代码如下:
<?php
$state = 0;
// check to see if verificaton code was correct
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
// if verification code was correct send the message and show this page
mail("myemail@gmail.com", 'Online Form: '.$subject, "\n".$message."
\n\n".$name."\n\n".$lastname."\n\n".$from."\n\n".$_SERVER['REMOTE_ADDR']." \n\n".'mailinglist: '.$mailinglist, "From: $from");
// delete the cookie so it cannot sent again by refreshing this page
setcookie('tntcon','');
$state = 2;
} else if(isset($message) and $message!=""){
// if verification code was incorrect then return to contact page and show error
$state = 1;
}
if ($state == 0) { ?>
我试着试着看看是否可以解决这个问题,但以为我会停下来,直到自己超越并完全搞砸了:
<td align="left"><input type=checkbox name="mailinglist" id="mailinglist" value="1<?php echo $_GET['mailinglist'];?>">Yes<input type=checkbox name="mailinglist" id="mailinglist" value="2<?php echo $_GET['mailinglist'];?>">No<font face="Verdana" size="3" color="#666666"></font><br> </td></tr><tr valign="top" align="right"> <td nowrap><font face="Verdana" size="3" color="#666666">comments (<span class="R">*</span>)</font></td>
如果要让电子邮件说明用户是否为恶意列表选择了“是”,请执行以下操作:
<td align="left">
<input type="radio" name="mailinglist" value="Yes" /> Yes
<input type="radio" name="mailinglist" value="No" /> No
</td>
在电子邮件中,您可以将选择打印为:
Mailing list: <?= $_POST['mailinglist'] ?>
假设您使用POST方法提交表单
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.