I am brand new to php. I would like to post multiple checkbox values in an email from a form when they are selected. Only the last option checked is coming through in the email, even if they are all selected in the form. I have tried many solutions I found on for this and can't seem to find one that works for me.
What am I doing wrong?
HTML:
<input type="checkbox" name="product-types-owned[]" value="Cast_Iron" />
<input type="checkbox" name="product-types-owned[]" value="Braisers" />
<input type="checkbox" name="product-types-owned[]" value="Ovens" />
<input type="checkbox" name="product-types-owned[]" value="Skillet" />
php:
$sendto = "email@email.com";
$usermail = $_POST['Email'];
$firstname = nl2br($_POST['First_name']);
$lastname = nl2br($_POST['Last_name']);
$address1 = nl2br($_POST['Address1']);
$address2 = nl2br($_POST['Address2']);
$city = nl2br($_POST['City']);
$state = nl2br($_POST['State']);
$zip = nl2br($_POST['Zip_Code']);
$phone = nl2br($_POST['Telephone']);
$ownership = nl2br($_POST['product-types-owned']);
$subject = "Product Registration";
$headers = "From: " . strip_tags($usermail) . "
";
$headers .= "Reply-To: ". strip_tags($usermail) . "
";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type: text/html;charset=utf-8
";
$msg = "<html><body style='font-family:Arial,sans-serif;'>";
$msg .= "<h2 style='font-weight:bold;border-bottom:1px dotted #ccc;'>Product Registration</h2>
";
$msg .= "<p><strong>Sent by:</strong> ".$usermail."</p>
";
$msg .= "<p><strong>First Name:</strong> ".$firstname."</p>
";
$msg .= "<p><strong>Last Name:</strong> ".$lastname."</p>
";
$msg .= "<p><strong>Address:</strong> ".$address1."</p>
";
$msg .= "<p><strong>Address Line 2:</strong> ".$address2."</p>
";
$msg .= "<p><strong>State:</strong> ".$state."</p>
";
$msg .= "<p><strong>Zip:</strong> ".$zip."</p>
";
$msg .= "<p><strong>Telephone:</strong> ".$phone."</p>
";
$msg .= "<p><strong>Products Own or Intend to Own:</strong> ".$ownership."</p>
";
$msg .= "</body></html>";
I have tried the solution here as well as changing
$ownership = nl2br($_POST['product-types-owned']);
to
$ownership = nl2br(implode(',', $_POST['product-types-owned']));
and I get an error: Warning: implode() [function.implode]: Invalid arguments passed in /home/content/99/11039499/html/scripts/warranty.php on line 24
Please help, I am so frustrated.