# Checkbox not sending all of data

**URL:** <https://forum.kirupa.com/t/checkbox-not-sending-all-of-data/299986>\
**Category:** programming\
**Created:** [November 13, 2009, 6:45pm UTC](https://forum.kirupa.com/t/checkbox-not-sending-all-of-data/299986 "2009-11-13T18:45:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hillarylaine](https://avatars.discourse-cdn.com/v4/letter/h/f17d59/32.png) [@Hillarylaine](https://forum.kirupa.com/u/Hillarylaine)\
**Post date:** [November 13, 2009, 6:45pm UTC](https://forum.kirupa.com/t/checkbox-not-sending-all-of-data/299986/1 "2009-11-13T18:45:15Z")

</div>

I have a form that is only returning the last box checked instead of all values that were checked. Please help, i’m pulling my hair out!:hair:

**[COLOR=red]html CODE for form:[/COLOR]**

\<!----this is where the Industries check box starts-----\>

```
          &lt;tr&gt;
            &lt;td height="175" colspan="2" align=left valign=top&gt;&lt;div style='width:350px;float:left;padding-top:5px;'&gt;&lt;b&gt;What best describes your organization? &lt;span style='color:#CC0000;font-size:125%;'&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
              &lt;br clear=all /&gt;
              &lt;table width="387"&gt;
                &lt;tr&gt;
                  &lt;td width="158"&gt;&lt;label&gt;
                    &lt;input type="checkbox" name="Industries[]" value="Aerospace" id="Aerospace" /&gt;
                    &lt;span class="Checkbox"&gt;Aerospace&lt;/span&gt;&lt;/label&gt;&lt;/td&gt;
                  &lt;td width="217" class="Checkbox"&gt;&lt;input type="checkbox" name="Industries[]" value="Manufacturing" id="Manufacturing" /&gt;
                    Manufacturing&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                  &lt;td&gt;&lt;label&gt;
                    &lt;input type="checkbox" name="Industries[]" value="Automotive" id="Automotive" /&gt;
                    &lt;span class="Checkbox"&gt;Automotive&lt;/span&gt;&lt;/label&gt;&lt;/td&gt;
                  &lt;td class="Checkbox"&gt;&lt;input type="checkbox" name="Industries[]" value="Mining" id="Mining" /&gt; 
                    Mining

```

\</td\>  
\</tr\>  
\<tr\>  
\<td\>\<span class=“Checkbox”\>  
\<label\>  
\<input type=“checkbox” name=“Industries[]” value=“Chemical” id=“Chemical” /\>  
Chemical\</label\>  
\</span\>\</td\>  
\<td\>\<span class=“Checkbox”\>  
\<input type=“checkbox” name=“Industries[]” value=“OilGas” id=“OilGas” /\>  
Oil & Gas\</span\>\</td\>  
\</tr\>  
\<tr\>  
\<td\>\<span class=“Checkbox”\>  
\<label\>  
\<input type=“checkbox” name=“Industries[]” value=“Education” id=“Education” /\>  
Education\</label\>  
\</span\>\</td\>  
\<td\>\<span class=“Checkbox”\>  
\<input type=“checkbox” name=“Industries[]” value=“Pharmaceutical” id=“Pharmaceutical” /\>  
Pharmaceutical\</span\>\</td\>  
\</tr\>  
\<tr\>  
\<td\>\<span class=“Checkbox”\>  
\<label\>  
\<input type=“checkbox” name=“Industries[]” value=“GovernmentFederal” id=“GovernmentFederal” /\>  
Government-Federal  
\</label\>  
\</span\>\</td\>  
\<td\>\<span class=“Checkbox”\>  
\<input type=“checkbox” name=“Industries[]” value=“Rail” id=“Rail” /\>  
Rail\</span\>\</td\>  
\</tr\>  
\<tr\>  
\<td\>\<span class=“Checkbox”\>  
\<label\>  
\<input type=“checkbox” name=“Industries[]” value=“GovernmentMunicipal” id=“GovernmentMunicipal” /\>  
Government-Municipal\</label\>\</span\>\</td\>  
\<td\>\<span class=“Checkbox”\>  
\<input type=“checkbox” name=“Industries[]” value=“Utility” id=“Utility” /\>  
Utility\</span\>\</td\>  
\</tr\>  
\<tr\>  
\<td\>\<span class=“Checkbox”\>  
\<label\>  
\<input type=“checkbox” name=“Industries[]” value=“GovernmentState” id=“GovernmentState” /\>  
Government-State\</label\>  
\</span\>\</td\>  
\<td\>\<span class=“Checkbox”\>  
\<input type=“checkbox” name=“Industries[]” value=“Other” id=“Other” /\>  
Other:  
\<label\>  
\<input name=“Other Explanation” type=“text” id=“OtherExplanation” size=“22” /\>  
\</label\>  
\</span\>\</td\>  
\</tr\>  
\</table\>  
\<div style=‘width:380px;float:left;padding-top:5px;’\>\<b\>\<span style=‘color:#CC0000;font-size:125%;’\> \</span\>\</b\>\</div\>  
\<br clear=all /\>  
\<table width=“381”\>  
\</table\>\</td\>

**[COLOR=red]PHP CODE to process form:[/COLOR]**

\<?php  
if(!isset($\_POST[‘submit’]))  
{  
//This page should not be accessed directly. Need to submit the form.  
echo “error; you need to submit the form!”;  
}  
$organizationname = $\_POST[‘OrganizationName’];  
$firstname = $\_POST[‘FirstName’];  
$lastname = $\_POST[‘LastName’];  
$businessemail = $\_POST[‘BusinessEmail’];  
$industries = $\_POST[‘Industries’];  
foreach ( $industries as $industry)  
{  
$msg .= "$industry  
";  
}  
$otherexplanation = $\_POST[‘OtherExplanation’];  
$newsletter = $\_POST[‘Newsletter’];

//Validate content entered  
if(empty($organizationname)||empty($firstname)||empty($lastname)||empty($businessemail))  
{  
echo (“Name and email are mandatory. Please go back and try again.”);  
exit;  
}

//validate newsletter has been selected  
if(empty($newsletter))  
{  
echo (“Please make sure you select a newsletter. Go back and try again.”);  
exit;  
}

//Adjust for Magic Quotes  
$firstname = stripslashes ($firstname);  
$lastname = stripslashes ($lastname);

//Trying to figure our the Arrays function!!!

//End of Trying to figure out the Array function!!!

$email\_from = ‘focus@arcadisweb.com’;//\<== update the email address  
$email\_subject = “New Focus Newsletter Sign-up”;  
$msg = "The results from the Focus Newsletter sign up form fields are below. (From [arcadisweb.com/focussignup.html](http://arcadisweb.com/focussignup.html))

";  
$msg .= "Industry chosen:  
$industry

";

$to = "[focus@arcadis-us.com";//](mailto:focus@arcadis-us.com%22;//)\<== update the email address  
$headers = "From: $email\_from  
";  
//Send the email!  
mail($to,$email\_subject,$msg,$headers);  
//done. redirect to thank-you page.  
header (‘Location: [http://www.arcadisweb.com/Thankyoupage.html](http://www.arcadisweb.com/Thankyoupage.html)’);  
//Function to validate against any email injection attempts  
function IsInjected($str)  
{  
$injections = array(’(  
+)’,  
‘(\r+)’,  
‘( +)’,  
‘(%0A+)’,  
‘(%0D+)’,  
‘(%08+)’,  
‘(%09+)’  
);  
$inject = join(’|’, $injections);  
$inject = “/$inject/i”;  
if(preg\_match($inject,$str))  
{  
return true;  
}  
else  
{  
return false;  
}  
}  
if(IsInjected($visitor\_email))  
{  
echo “Bad email value!”;  
exit;  
}

?\>
