# Check Box Arrays

**URL:** <https://www.phphelp.com/t/check-box-arrays/10247>\
**Category:** Beginners - Learning PHP\
**Created:** [August 26, 2007, 12:57pm UTC](https://www.phphelp.com/t/check-box-arrays/10247 "2007-08-26T12:57:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![astor7](https://www.phphelp.com/letter_avatar_proxy/v4/letter/a/b9e5f3/32.png) [@astor7](https://www.phphelp.com/u/astor7)\
**Post date:** [August 26, 2007, 12:57pm UTC](https://www.phphelp.com/t/check-box-arrays/10247/1 "2007-08-26T12:57:06Z")

</div>

Okay… So I’m starting to go crazy because this is the only thing holding me back from launching the final product.

I have a “application” form that I’ve downloaded, and I got the jist of modifying it really quickly.

here is a scaled down Version of my config.php

```auto
<?php
@$Features = addslashes($_POST['Features']);
require_once("check.php"); 

if (! ereg('[A-Za-z0-9_-]+@[A-Za-z0-9_-]+.[A-Za-z0-9_-]+', $email))

{

header("Location: error.html");

exit;

}

$pfw_header = "From: $email";
$pfw_subject = "Application Has Arrived";
$pfw_email_to = "email@domain.com";
$pfw_message = "First Name: $NameFirstn"

. "Features: $Featuresn"
. "";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
$pfw_header = "From: email@domain.com";
$pfw_subject = "Confirmation";
$pfw_email_to = "$email";
$pfw_message = "We have recieved your Application.n"
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
header("Location: thank-you.html");

?>

```

Pretty cut and Dry. So now I’ll explain what’s going on.

On my index.html of this directory I have

```auto
<table width="100%" height="165" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td width="100%" valign="top"> 
  <tr>
      <td><form method="post" action="contact.php">
  
          <table width="540" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr> 
              <td></td>
            </tr>
<tr>
<td>
<font size="2">
Please Check all that apply:
</font>
<p>
<input type="checkbox" value="Dining Room" name="Features[]" > 
                            <font face="Verdana" size="1">Dining Room</font>

<input type="checkbox" value="Family Room" name="Features[]" > 
                            <font face="Verdana" size="1">Family Room&nbsp;&nbsp;</font>

<input type="checkbox" value="Living Room" name="Features[]" > 
                            <font face="Verdana" size="1">Living Room&nbsp;&nbsp;</font>

<input type="checkbox" value="Bonus Room" name="Features[]" > 
                            <font face="Verdana" size="1">Bonus Room&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font>

<p>
<input type="checkbox" value="Fire Place" name="Features[]" > 
                            <font face="Verdana" size="1">Fire Place&nbsp;&nbsp;&nbsp;&nbsp</font>
<input type="checkbox" value="Central Air" name="Features[]" > 
                            <font face="Verdana" size="1">Central Air &nbsp;&nbsp;&nbsp;&nbsp;</font>
<input type="checkbox" value="Deck" name="Features[]" > 
                            <font face="Verdana" size="1">Deck&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font>
<input type="checkbox" value="Above Ground Pool" name="Features[]" > 
                            <font face="Verdana" size="1">Above Ground Pool</font>

<p>

<input type="checkbox" value="Great Room" name="Features[]" > 
                            <font face="Verdana" size="1">Great Room&nbsp;</font>
<input type="checkbox" value="In Ground Pool" name="Features[]" > 
                            <font face="Verdana" size="1">In Ground Pool</font>
<input type="checkbox" value="Screened Patio" name="Features[]" > 
                            <font face="Verdana" size="1">Screened Patio</font>
<input type="checkbox" value="Screened Pool Enclosure" name="Features[]" > 
                            <font face="Verdana" size="1">Screened Pool Enclosure</font>
<p>
<input type="checkbox" value="Fence" name="Features[]" > 
                            <font face="Verdana" size="1">Fence&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font>
<input type="checkbox" value="Central Heat" name="Features[]" > 
                            <font face="Verdana" size="1">Central Heat</font>

</tr>
```

Now, when I send any information like a Radio Button, or just a text box

The E-mail Sends the information correctly. So i added the check boxes in and put them in the same way. I was only getting 1 of the several that I checked to show up…So i used our good friend Google and found out they had to be in an array. So I added the [] at the end of the name. When I go to my config .php and have . “Features: $Features[0] $Features[1] $Features[2] $Features[3] $Features[4]n” instead of just $Features It just spells “A r r a y” to me in the e-mail. I’m going nuts here, and I just can’t figure this out. If anyone can tell me how to make my checkbox array work I would really appreciate it.

Thanks

astor7

---

<div class="post-metadata">

**Author:** ![Q1712](https://www.phphelp.com/letter_avatar_proxy/v4/letter/q/a183cd/32.png) [@Q1712](https://www.phphelp.com/u/Q1712)\
**Post date:** [August 27, 2007, 12:03am UTC](https://www.phphelp.com/t/check-box-arrays/10247/2 "2007-08-27T00:03:54Z")

</div>

thats because of this line:  
[php]@$Features = addslashes($\_POST[‘Features’]);[/php]

addslashes expects the parameter to be a string.  
because it’s an array is gets converted to the string ‘Array’.

then u use the []-operator with a string. that will return the char at the specefied position.

---

<div class="post-metadata">

**Author:** ![astor7](https://www.phphelp.com/letter_avatar_proxy/v4/letter/a/b9e5f3/32.png) [@astor7](https://www.phphelp.com/u/astor7)\
**Post date:** [August 27, 2007, 12:32am UTC](https://www.phphelp.com/t/check-box-arrays/10247/3 "2007-08-27T00:32:43Z")

</div>

So it’s just this ?

[php]  
@$Features = ($\_POST[‘Features’]);  
[/php]
