# PHP Checkbox code help

**URL:** <https://forum.kirupa.com/t/php-checkbox-code-help/296965>\
**Category:** programming\
**Created:** [September 23, 2009, 1:03pm UTC](https://forum.kirupa.com/t/php-checkbox-code-help/296965 "2009-09-23T13:03:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubberduckie](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@rubberduckie](https://forum.kirupa.com/u/rubberduckie)\
**Post date:** [September 23, 2009, 1:03pm UTC](https://forum.kirupa.com/t/php-checkbox-code-help/296965/1 "2009-09-23T13:03:21Z")

</div>

I am having a hard time getting my php to work with my html. I have several sets of checkboxes and I believe that is what is not coded right. Can someone please help???

Here is the code in html and php for my checkboxes. Right now when I sumbit it sends me to a page that says “blarg!”

```auto
<form method="POST" action="mailer.php" ><p><strong>Was this contact (check all that apply)</strong></p>
            
  <label>
              <input name="contact" type="checkbox" value="In person" />
              In person</label>
          <br />
                <label>
              <input name="contact" type="checkbox" value="By phone" />
              By phone</label>
          <br />
                <label>
              <input name="contact" type="checkbox" value="By email" />
              By email</label>
          <br />
                <label>
              <input name="contact" type="checkbox" value="Fax" />
              Fax</label>
          <br />
                <label>
              <input name="contact" type="checkbox" value="No contact with the Financial Aid Office" />
              No contact with the Financial Aid Office</label>
          <br />
                <label>
              <input name="contact" type="checkbox" value="Other" />
              Other</label>
          <p><strong>What was the nature of your visit(s)? (check all the apply)</strong></strong><br />
            <label>
              <input name="nature" type="checkbox" value="Loan question/assistance" />
              Loan question/assistance</label>
              <br />
              <label>
              <input name="nature" type="checkbox" value="Scholarship question/assistance" />
              Scholarship question/assistance</label>
              <br />
              <label>
              <input name="nature" type="checkbox" value="Application/FAFSA assistance" />
              Application/FAFSA assistance</label>
              <br />
              <label>
              <input name="nature" type="checkbox" value="Debt load counseling" />
              Debt load counseling</label>
              <br />
              <label>
              <input name="nature" type="checkbox" value="HPSP question/counseling" />
              HPSP question/counseling</label>
              <br />
              <label>
              <input name="nature" type="checkbox" value="Special Circumstances Appeal" />
              Special Circumstances Appeal</label>
              <br />
              <label>
              <input name="nature" type="checkbox" value="No contact with the Financial Aid Office2" />
              No contact with the Financial Aid Office</label>
          </p> </form>

```

```php
<?php
if(isset($_POST['submit'])) { 
$to = xxx@myemail.com; 
$subject = "Financial Aid Survey"; foreach($_POST['checkbox'] as $value) { 
$checkbox_msg .= "Checked: $contact
";} 
foreach($_POST['checkbox'] as $value) { 
$checkbox_msg .= "Checked: $nature
";} 
$body =Was this contact: $contact
 
What was the nature of your visit: $nature
; 

echo "Thank you! Your information has been submitted to $to!"; 
mail($to, $subject, $body); 
} else { 
echo "blarg!"; 
} 
?> 

```

Thank you!
