Got some great help yesterday with some php code for a mailer and forgot that I also need to know how to include the code so the mailer knows which option is checked in the checkbox. It is a simple ‘join mailing list’ option with only a yes or no option available.
Code is as follows:
<?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) { ?>
I tried playing with this a bit to see if I could figure it out, but thought I would stop before I get ahead of myself and totally mess it up:
<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>
If you want the email to say whether the user selected Yes for maling list do the following:
and in the email you can print the selection as:
assuming that you used method POST for form submission