Page 1 of 1

php mailer form, multiple checkboxes

Posted: Mon Sep 08, 2008 12:48 pm
by rimmet
Hi,

Im looking for some help. Ive been tearing my hair out for the last 3hours trying to work this one out.

Ive got a html form that Im looking to pass the values to a php file to mail them to my email address.

I am very new to php, well just teaching myself by looking at other peoples code and have managed to get a piece of php code to work with all other parts of my form apart from the area that has multiple checkboxes.

Ive got a column of checkboxes with a javascript function only allowing the user to select a maximum of three.

I want the the values of the three boxes selected to be passed to the php and then emailed onto my like all of the other values.

Except all I am getting is the bottom selected checkbox, not the other two!

I will post up the part of my form and my whole php script.

I really appreciate any help / advice and peoples time and efforts

Thanks
Thom

=====HTML=====

<td width="100" valign="top">
Of the following elements of online marketing please select the three that... </td>
<td width="30" valign="top">

<h5>you feel have the greatest impact in delivering marketing objectives.</h5>

<input type="checkbox" name="Q5C1" value="1" onclick="chkcontrol(0)";> eDetailing</input><br><br>

<input type="checkbox" name="Q5C1" value="2" onclick="chkcontrol(1)";> eCME</input><br><br>

<input type="checkbox" name="Q5C1" value="3" onclick="chkcontrol(2)";> eNewsletters</input><br><br>

<input type="checkbox" name="Q5C1" value="4" onclick="chkcontrol(3)";> eMail marketing</input><br><br>

<input type="checkbox" name="Q5C1" value="5" onclick="chkcontrol(4)";> Closed Loop Marketing</input><br><br>

<input type="checkbox" name="Q5C1" value="6" onclick="chkcontrol(5)";> Online Market Research</input><br><br>

<input type="checkbox" name="Q5C1" value="7" onclick="chkcontrol(6)";> ePublic Relations</input><br><br>

<input type="checkbox" name="Q5C1" value="8" onclick="chkcontrol(7)";> Brand websites</input><br><br>

<input type="checkbox" name="Q5C1" value="9" onclick="chkcontrol(8)";> Company</input><br><br>

<input type="checkbox" name="Q5C1" value="10" onclick="chkcontrol(9)";> Disease area website</input><br><br>

<input type="checkbox" name="Q5C1" value="11" onclick="chkcontrol(10)";> eMail campaigns</input><br><br>

<input type="checkbox" name="Q5C1" value="12" onclick="chkcontrol(11)";> Online advisory boards</input><br><br>

<input type="checkbox" name="Q5C1" value="13" onclick="chkcontrol(12)";> Social Networks</input><br><br>

<input type="checkbox" name="Q5C1" value="14" onclick="chkcontrol(13)";> Blogging and Podcasting</input><br><br>

<input type="checkbox" name="Q5C1" value="15" onclick="chkcontrol(14)";> Podcasting</input><br><br>

<input type="checkbox" name="Q5C1" value="16" onclick="chkcontrol(15)";> Webcasting</input><br><br>

<input type="checkbox" name="Q5C1" value="17" onclick="chkcontrol(16)";> Online reputation monitoring/management</input><br><br>

<input type="checkbox" name="Q5C1" value="18" onclick="chkcontrol(17)";> SMS marketing</input><br><br>

<input type="checkbox" name="Q5C1" value="19" onclick="chkcontrol(18)";> Twitter</input>

</td>


=====PHP=====

<script language="php">
$email = $HTTP_POST_VARS[email];
$mailto = "thom.rimmer@hotmail.co.uk";
$mailsubj = "Form submission";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from web site form:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $val\n"; }
if (!eregi("\n",$HTTP_POST_VARS[email])) { mail($mailto, $mailsubj, $mailbody, $mailhead); }
</script>

Re: php mailer form, multiple checkboxes

Posted: Mon Sep 08, 2008 1:20 pm
by ahowell
you need to add the part in red:

Code: Select all

<input type="checkbox" name="Q5C1[color=#FF0000][b][][/b][/color]" value="1" onclick="chkcontrol(0)";> eDetailing</input><br><br>

Re: php mailer form, multiple checkboxes

Posted: Mon Sep 08, 2008 1:47 pm
by rimmet
Hi

When I do that in the emailed results I just get Array instead of the numbers, am I missing another part?

Thanks again
Thom