Php email checkboxes

I have a simple question (I hope). I have a simple php email script and a simple html form. I need to know how to code the checkbox fields in the form, as well as how to include them in the email php script. Thanks.
isaacr25Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Loganathan NatarajanLAMP DeveloperCommented:
you have to print those form design with html design in the mail body script ...which will be sending through the mail..

0
Jason C. LevineNo oneCommented:
Isaac,

The easiest thing to do is to have the checkbox fields have different names.  Then, PHP will treat each one as a separate field.

If you want to store all checked values in a single field, that's certainly possible, but a bit trickier.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
v2MediaCommented:
The easiest way is to let php group the checkbox values into an array. This is done by giving every checkbox in the form that's grouped together the same name and a set of square brackets appended to that name e.g.

<input type="checkbox" name="options[]" value="option one value" />
<input type="checkbox" name="options[]" value="option two value" />
<input type="checkbox" name="options[]" value="option three value" />

The form values are then accessed in php like so:
<?php
 
$arr_options = (!empty($_POST['options'])) ? $_POST['options'] : false;
 
if($arr_options) {
 
  foreach($arr_options as $k => $v) {
 
    echo $k . ' option = ' . $v;
 
  }
 
}
 
?>

Open in new window

0
Marcus BointonCommented:
Bear in mind that unchecked checkboxes do not get submitted with the form, so you need to work out which ones were unchecked by elimination.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.