Help with getting multi check boxes to send to email

I have been searching all over the internet for a way to get multiple check boxes to print to an email.
I have been working on this for days and I just can’t seen to find a way to do it. Everything works fine except for the check boxes, I have tried many many different snippets of code to try to get this to email me the results of the checked boxes.

Can you please help me to get this working?
Any help would greatly appreciate it.

The code I am using is below


$your_email =‘[email protected]’;// <<=== update to your email address

$errors = ‘’;
$name = ‘’;
$visitor_email = ‘’;
$user_message = ‘’;


$name = $_POST['name'];
$visitor_email = $_POST['email'];
$visitor_q1 = $_POST['q1'];
$gender = $_POST['gender'];
$Preferred = $_POST['preflang'];
$user_message = $_POST['message'];
///------------Do Validations-------------
	$errors .= "\n Name and Email are required fields. ";	
	$errors .= "\n Bad email value!";
if(empty($_SESSION['6_letters_code'] ) ||
  strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0)
//Note: the captcha code is compared case insensitively.
//if you want case sensitive match, update the check above to
// strcmp()
	$errors .= "\n The captcha code does not match!";

	//send the email
	$to = $your_email;
	$subject="New form submission";
	$from = $your_email;
	$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
	$body = "A user  $name submitted the contact form:\n".
	"Full Name: $name\n".
	"Email: $visitor_email \n".
	"Gender: $gender \n".
	"Preferred Language: $preflang \n".
    "Q1: $visitor_q1 \n".
	"Message: \n ".
	"IP: $ip\n";
	$headers = "From: $from \r\n";
	$headers .= "Reply-To: $visitor_email \r\n";
	mail($to, $subject, $body,$headers);
	header('Location: thank_you.htm');


// Function to validate against any email injection attempts
function IsInjected($str)
$injections = array(’(\n+)’,
$inject = join(’|’, $injections);
$inject = “/$inject/i”;
return true;
return false;


Untitled Document <?php if(!empty($errors)){ echo "


"; } ?>

Full Name:



First: <input type=“checkbox” name=“boxes[]” value=“first” <?php echo (is_array($_POST['boxes']) && in_array('first', $_POST['boxes'])) ? 'checked = "checked"' : ''; ?>>

Second: <input type=“checkbox” name=“boxes[]” value=“second” <?php echo (is_array($_POST['boxes']) && in_array('second', $_POST['boxes'])) ? 'checked = "checked"' : ''; ?>>

Third: <input type=“checkbox” name=“boxes[]” value=“third” <?php echo (is_array($_POST['boxes']) && in_array('third', $_POST['boxes'])) ? 'checked = "checked"' : ''; ?>>


My gender is:

<input type=“radio” name=“gender” value=“male” <?php echo $_POST['gender'] == 'male' ? 'selected="selected"' : ''; ?>/>

<input type=“radio” name=“gender” value=“female” <?php echo $_POST['gender'] == 'female' ? 'selected="selected"' : ''; ?>/>

My preferred language is:

<input type=“radio” name=“preflang” value=“en” <?php echo $_POST['preflang'] == 'en' ? 'selected="selected"' : ''; ?>/>

<input type=“radio” name=“preflang” value=“fr” <?php echo $_POST['preflang'] == 'fr' ? 'selected="selected"' : ''; ?>/>

<input type=“radio” name=“preflang” value=“es” <?php echo $_POST['preflang'] == 'es' ? 'selected="selected"' : ''; ?>/>


<?php echo htmlentities($user_message) ?>

Enter the code above here :

Can't read the image? click here to refresh


The above code is all in one file. You can see it online at

Try this:
[php]if(is_array($_POST[“boxes”])) $boxes=implode(’, ',$_POST[“boxes”]);[/php]

And then add $boxes to your $body variable.

Thank you for your quick reply,
I am really bad when it comes to php. can you direct me to where I need to insert this code
Thank you for your help

I inserted it in the bold spots below with no results in including it in the email results

$your_email =‘[email protected]’;// <<=== update to your email address

$errors = ‘’;
$name = ‘’;
$visitor_email = ‘’;
$user_message = ‘’;


$name = $_POST['name'];
$visitor_email = $_POST['email'];
$visitor_q1 = $_POST['q1'];
$gender = $_POST['gender'];
$Preferred = $_POST['preflang'];
[b]$boxes = $_POST['boxes'];[/b]
$user_message = $_POST['message'];
[b]if(is_array($_POST["boxes"])) $boxes=implode(', ',$_POST["boxes"]);[/b][/php]

I Think I have it

[php] $name = $_POST[‘name’];
$visitor_email = $_POST[‘email’];
$visitor_q1 = $_POST[‘q1’];
$gender = $_POST[‘gender’];
$Preferred = $_POST[‘preflang’];
$boxes = $_POST[‘boxes’];
$user_message = $_POST[‘message’];
if(is_array($_POST[“boxes”])) $boxes=implode(’, ',$_POST[“boxes”]);[/php]


[php] $body = “A user $name submitted the contact form:\n”.
“Full Name: $name\n”.
“Email: $visitor_email \n”.
“Gender: $gender \n”.
“Preferred Language: $preflang \n”.
“Q1: $visitor_q1 \n”.
“Boxes: $boxes \n”.
"Message: \n ".
“IP: $ip\n”;[/php]

Thank you for your help. If I need a php coder I know where to look.

No problem. You can also eliminate this line (it is not needed there):
[php]$boxes = $_POST[‘boxes’];[/php]

Yep I took that out already. You are the first php programmer that has been helpful with straight forward answers. Once I can see what has to happen I can study it and understand function and principal. Now I can work through a few other issues I have on my own
Thank you for all your help.

Sponsor our Newsletter | Privacy Policy | Terms of Service