# PHP Contact Form - Checkboxes

**URL:** <https://forum.kirupa.com/t/php-contact-form-checkboxes/209601>\
**Category:** programming\
**Created:** [December 10, 2006, 7:14pm UTC](https://forum.kirupa.com/t/php-contact-form-checkboxes/209601 "2006-12-10T19:14:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![genoasboy](https://avatars.discourse-cdn.com/v4/letter/g/ed655f/32.png) [@genoasboy](https://forum.kirupa.com/u/genoasboy)\
**Post date:** [December 10, 2006, 7:14pm UTC](https://forum.kirupa.com/t/php-contact-form-checkboxes/209601/1 "2006-12-10T19:14:14Z")

</div>

I’m trying to create a contact form with 3 different questions each with a different set of checkboxes. The form works fine but the data I receive from the form displays the same values for the first set of checkboxes.

How to get my form to return different values for the different sets of checkboxes.  
Here’s my HTML code:  
\<form method=“POST” action="…/sponsor/sponapp.php"\>  
\<p\>\<br /\>  
Name of Event:  
\<input name=“eventname” type=“text” id=“eventname” size=“19” /\>  
\<br /\>  
\<br /\>  
Organizers Name :  
\<input name=“organizer” type=“text” id=“organizer” size=“19” /\>  
\<br\>  
\<br\>  
Area/City:  
\<input name=“area” type=“text” id=“area” size=“19”\>  
\<br /\>  
\<span class=“style2”\>\<br /\>  
\<span class=“style11”\>Date Submitted:\</span\>  
\<input name=“submitted” type=“text” id=“submitted” size=“19” /\>  
\<br /\>  
\</span\>\<br\>  
Level of Sponsorship request \<br\>  
\<textarea name=“level” cols=“25” rows=“3” id=“level”\>\</textarea\>  
\<br /\>  
\<span class=“style2”\>\<br /\>  
\<span class=“style11”\>Sponsorship Amount:$\</span\>  
\<input name=“sponamount” type=“text” id=“sponamount” size=“19” /\>  
\</span\>\<br /\>  
\<br /\>  
\<br /\>  
Date(s) of Event :  
\<input name=“eventdate” type=“text” id=“eventdate” size=“19” /\>  
\<table width=“247” cellspacing=“0” cellpadding=“1”\>  
\<tr\>  
\<td colspan=“2”\>\<br /\>  
Type of Event\</td\>  
\</tr\>  
\<tr\>  
\<td width=“243”\>\<input name=“check[]” type=“checkbox” id=“check[]” value=“community” /\>  
\<span class=“style2”\>Community\</span\>\<br /\>  
\<input name=“check[]” type=“checkbox” id=“check[]” value=“education” /\>  
\<span class=“style2”\>Education\<br /\>  
\<input name=“check[]” type=“checkbox” id=“check[]” value=“entertainment” /\>  
Entertainment\</span\>\</td\>  
\<td width=“243”\>\<input name=“check[]” type=“checkbox” id=“check[]” value=“fashion” /\>  
\<span class=“style2”\>Fashion\</span\>\<br /\>  
\<input name=“check[]” type=“checkbox” id=“check[]” value=“special event” /\>  
\<span class=“style2”\>Special Event \<br /\>  
\<input name=“check[]” type=“checkbox” id=“check[]” value=“sporting” /\>  
Sporting\</span\>\</td\>  
\</tr\>  
\</table\>  
\<br /\>  
\<table width=“372” cellspacing=“0” cellpadding=“1”\>  
\<tr\>  
\<td colspan=“3”\>Audience\</td\>  
\</tr\>  
\<tr\>  
\<td width=“103” height=“22”\>\<input name=“check[]2” type=“checkbox” id=“check[]2” value=“men/women” /\>  
\<span class=“style2”\>Men&Women\</span\>\<br /\>\</td\>  
\<td width=“144”\>\<input name=“check[]2” type=“checkbox” id=“check[]2” value=“adult males” /\>  
\<span class=“style10”\>Mainly adult males\</span\>\<br /\>\</td\>  
\<td width=“117”\>\<input name=“check[]2” type=“checkbox” id=“check[]2” value=“children” /\>  
\<span class=“style2”\>Mainly children\</span\>\</td\>  
\</tr\>  
\</table\>  
\<p\>Estimated number of attendance:  
\<input name=“attendance” type=“text” id=“attendance” size=“8” /\>  
\<br /\>  
\<br /\>  
Estimated number of participants:  
\<input name=“participants” type=“text” id=“participants” size=“8” /\>

\<table width=“346” cellspacing=“0” cellpadding=“2”\>  
\<tr\>  
\<td height=“14” colspan=“2”\>\<div align=“center”\>\<strong\>Please fill out contact details\</strong\>\</div\>\</td\>  
\</tr\>  
\<tr\>  
\<td width=“49” height=“26”\>Name \</td\>  
\<td width=“362”\>\<input name=“name” type=“text” id=“name” size=“30” /\>\</td\>  
\</tr\>  
\<tr\>  
\<td height=“14”\>Position \</td\>  
\<td height=“14”\>\<input name=“position” type=“text” id=“position” size=“30” /\>\</td\>  
\</tr\>  
\<tr\>  
\<td height=“14”\>Organization\</td\>  
\<td height=“14”\>\<input name=“organization” type=“text” id=“organization” size=“30” /\>\</td\>  
\</tr\>  
\<tr\>  
\<td height=“14”\>Address \</td\>  
\<td height=“14”\>\<textarea name=“address” cols=“25” rows=“3” id=“address”\>\</textarea\>\</td\>  
\</tr\>  
\<tr\>  
\<td height=“14”\>Phone\</td\>  
\<td height=“14”\>\<input name=“phone” type=“text” id=“phone” size=“19” /\>\</td\>  
\</tr\>  
\<tr\>  
\<td height=“7”\>Fax\</td\>  
\<td height=“7”\>\<input name=“fax” type=“text” id=“fax” size=“19” /\>\</td\>  
\</tr\>  
\<tr\>  
\<td height=“7”\>Email\</td\>  
\<td height=“7”\>\<input name=“email” type=“text” id=“email” size=“30” /\>\</td\>  
\</tr\>  
\</table\>  
\<br /\>  
\<table width=“459” cellspacing=“0” cellpadding=“1”\>  
\<tr\>  
\<td colspan=“3”\>Please give details of exposure DTLR will receive from this sponsorship. \<br /\>  
Such as:\</td\>  
\</tr\>  
\<tr\>  
\<td width=“111” height=“22”\>\<input name=“check[]” type=“checkbox” id=“check[]” value=“radio” /\>  
\<span class=“style2”\>Radio Mentions \</span\>\<br /\>\</td\>  
\<td width=“132”\>\<input name=“check[]” type=“checkbox” id=“check[]” value=“media” /\>  
\<span class=“style10”\>Media Releases\</span\> \<br /\>\</td\>  
\<td width=“208”\>\<input name=“check[]” type=“checkbox” id=“check[]” value=“logos” /\>  
\<span class=“style2”\>Logos on flyers \</span\>\</td\>  
\</tr\>  
\<tr\>  
\<td height=“22”\>\<input name=“check[]” type=“checkbox” id=“check[]” value=“signage” /\>  
\<span class=“style2”\>Event signage \</span\>\</td\>  
\<td\>\<input name=“check[]” type=“checkbox” id=“check[]” value=“website” /\>  
\<span class=“style2”\>Website \</span\>\</td\>  
\<td\>\<input name=“check[]” type=“checkbox” id=“check[]” value=“TV” /\>  
\<span class=“style2”\>TV advertising\</span\>\</td\>  
\</tr\>  
\<tr\>  
\<td height=“22”\>\<input name=“check[]” type=“checkbox” id=“check[]” value=“other” /\>  
\<span class=“style2”\>Other\</span\>\</td\>  
\<td\>&nbsp;\</td\>  
\<td\>&nbsp;\</td\>  
\</tr\>  
\</table\> \<p\>Additional Event Details: (Please refer to sponsorship criteria) \<br /\>  
\<textarea name=“details” cols=“25” rows=“5” id=“details”\>\</textarea\>  
\<br /\>  
\<br /\>  
\<input type=“submit” value=“Submit” name=“submit” /\>  
\</form\>

Here’s the php code:  
\<?php  
if(isset($\_POST[‘submit’])) {

$to = “[erik@jdoubledesign.com](mailto:erik@jdoubledesign.com)”;  
$subject = “Sponsorship Application”;  
$event\_field = $\_POST[‘eventname’];  
$organizer\_field = $\_POST[‘organizer’];  
$area\_field = $\_POST[‘area’];  
$date\_field = $\_POST[‘submitted’];  
$level\_field = $\_POST[‘level’];  
$amount\_field = $\_POST[‘sponamount’];  
$date2\_field = $\_POST[‘eventdate’];  
$attendance\_field = $\_POST[‘attendance’];  
$participant\_field = $\_POST[‘participants’];  
$name\_field = $\_POST[‘name’];  
$position\_field = $\_POST[‘position’];  
$organization\_field = $\_POST[‘organization’];  
$address\_field = $\_POST[‘address’];  
$phone\_field = $\_POST[‘phone’];  
$fax\_field = $\_POST[‘fax’];  
$email\_field = $\_POST[‘email’];  
$details\_field = $\_POST[‘details’];

foreach($\_POST[‘check’] as $value) {  
$check\_msg .= "Checked: $value  
";  
}

$body = "Name of Event: $event\_field  
Organizer: $organizer\_field  
Area/City: $area\_field  
Level of Sponsorship: $level\_field  
Sponsorship  
Amount: $amount\_field  
Event Date: $date2\_field  
$check\_msg  
$check\_msg  
Attendance: $attendance\_field  
Participants: $participant\_field  
Name: $name\_field  
Position: $position\_field  
Organization: $organization\_field  
Address: $address\_field  
Phone: $phone\_field  
Fax: $fax\_field  
Email: $email\_field $check\_msg Details: $detail\_field  
";  
echo “Data has been submitted to $to!”;  
mail($to, $subject, $body);

} else {  
echo “blarg!”;  
}  
?\>
