PHP with HTML form

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

Post Reply
Doughboy5170
Forum Newbie
Posts: 2
Joined: Tue Nov 11, 2003 8:01 pm

PHP with HTML form

Post by Doughboy5170 »

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!
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

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

&lt;input type="checkbox" value="1" NAME="Interiora&#1111;1]"&gt;Living room&lt;BR&gt;
&lt;input type="checkbox" value="1" NAME="Interiora&#1111;2]"&gt;Fireplace&lt;BR&gt;
 &lt;/TD&gt;
&lt;TD&gt;
&lt;input type="checkbox" value="1" NAME="Interiora&#1111;3]"&gt;Den/study&lt;BR&gt;
&lt;input type="checkbox" value="1" NAME="Interiora&#1111;4]"&gt;Family Room&lt;BR&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;input type="checkbox" value="1" NAME="Interiora&#1111;5]"&gt;Hardwood Floors&lt;BR&gt;
&lt;input type="checkbox" value="1" NAME="Interiora&#1111;6]"&gt;Laundry room&lt;BR&gt;
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.
Post Reply