PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Doughboy5170
Forum Newbie
Posts: 2 Joined: Tue Nov 11, 2003 8:01 pm
Post
by Doughboy5170 » Tue Nov 11, 2003 8:01 pm
Right now, I am trying to make a PHP form send the info collected from a realtor form. I want the info to be emailed. My only problem is that when I use a checkbox and have more than one box checked only the last box that is checked will show up.
This is the HTML part of the page:
Code: Select all
<input type="checkbox" value="1" NAME="Interiora">Living room<BR>
<input type="checkbox" value="2" NAME="Interiora">Fireplace<BR>
</TD>
<TD>
<input type="checkbox" value="3" NAME="Interiora">Den/study<BR>
<input type="checkbox" value="4" NAME="Interiora">Family Room<BR>
</TD>
<TD>
<input type="checkbox" value="5" NAME="Interiora">Hardwood Floors<BR>
<input type="checkbox" value="6" NAME="Interiora">Laudry room<BR>
This is the PHP part:
Code: Select all
<?php
"\n\nInterior Features - ".$HTTP_POST_VARS["Interiora"].
?>
Can anyone tell me what I am doing wrong, everything else in the email shows up fine, except this part it will only show "6" if I check all the boxes
Thanks for your help!
DuFF
Forum Contributor
Posts: 495 Joined: Tue Jun 24, 2003 7:49 pm
Location: USA
Post
by DuFF » Tue Nov 11, 2003 8:23 pm
Search on this forum, there have been many posts about this. The main problem is that you need to have the checkboxes as an array, not just a variable.
So you would want:
Code: Select all
<input type="checkbox" value="1" NAME="Interioraї1]">Living room<BR>
<input type="checkbox" value="1" NAME="Interioraї2]">Fireplace<BR>
</TD>
<TD>
<input type="checkbox" value="1" NAME="Interioraї3]">Den/study<BR>
<input type="checkbox" value="1" NAME="Interioraї4]">Family Room<BR>
</TD>
<TD>
<input type="checkbox" value="1" NAME="Interioraї5]">Hardwood Floors<BR>
<input type="checkbox" value="1" NAME="Interioraї6]">Laundry room<BR>
You could check the results by doing something like this:
Code: Select all
<?php
if ($Interiora[1] == "1")
{
echo "Living Room was checked!";
}
// repeat for others . . . (BTW, i put all values as 1)
?>
Note: I haven't checked this, I'm pretty sure it works but I've never tested it.