Check Box Arrays

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

@$Features = addslashes($_POST['Features']);

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


header("Location: error.html");



$pfw_header = "From: $email";
$pfw_subject = "Application Has Arrived";
$pfw_email_to = "[email protected]";
$pfw_message = "First Name: $NameFirstn"

. "Features: $Featuresn"
. "";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
$pfw_header = "From: [email protected]";
$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

<table width="100%" height="165"  border="0" cellpadding="0" cellspacing="0">
              <td width="100%" valign="top"> 
      <td><form method="post" action="contact.php">
          <table width="540" border="0" align="center" cellpadding="0" cellspacing="0">
<font size="2">
Please Check all that apply:
<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>

<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>


<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>
<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>


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.



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.

So it’s just this ?

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

Sponsor our Newsletter | Privacy Policy | Terms of Service