PDA

Click to See Complete Forum and Search --> : Webform Checkboxes not showing in resulting email


rlgriffo
07-18-2008, 05:27 AM
Hi,

I have 2 sets of check boxes on my online form, I cant get either to display in the resulting email...i know im doing something wrong, i just dont know what. It has a php & html part so I will put them here and hopefully someone can point me in the right direction....

Thank you very much in advance!!
************************************************** ****
HTML SIDE
************************************************** ****

<form method="post" action="testmailer.php">
<input type="hidden" name="sub" value="1">

<table border="0">


<tr>
<td colspan="6">&nbsp;</td>
</tr>
<tr>
<td colspan="6"><span style="font-weight: bold">What colour do you like?</span></td>
</tr>
<tr>
<td>blue</td>
<td id="checkbox"><input type="checkbox" name="check[]" value="blue" id="blue" /></td>
<td>red</td>
<td id="checkbox"><input type="checkbox" name="check[]" value="red" id="red" /></td>
<td id="name">yellow</td>
<td id="checkbox"><input type="checkbox" name="check[]" value="yellow" id="yellow" /></td>
</tr>


<tr>
<td colspan="6"><span style="font-weight: bold">What size would you like?</span></td>
</tr>
<tr>
<td>large</td>
<td><input type="checkbox" name="check[]" value="large" id="large" /></td>
<td>medium</td>
<td><input type="checkbox" name="check[]" value="medium" id="medium" /></td>
<td>small</td>
<td><input type="checkbox" name="check[]" value="small" id="small" /></td>
</tr>

<tr>
<td colspan="2">&nbsp;</td>
<td colspan="2">&nbsp;</td>
<td colspan="2"><label>
<input name="submit" type="submit" rows="9" value="submit" columns=50 id="submit">
</label></td>
</tr>
</table>
</form>

************************************************** ****
PHP SIDE
************************************************** ****


<?php
if(isset($_POST['submit'])) {
$to = "rachellegriffin@people.net.au";
$subject = "mailform";

foreach($_POST['check'] as $value) {
$check_msg .= "Colour: $value\n";
}

foreach($_POST['check'] as $value) {
$check_msg .= "Size: $value\n";
}

$body = "$colour_msg
$size_msg";


echo "Your inquiry has been successfully submitted.";
mail($to, $subject, $body);
} else {
echo "There was a a problem submitting your form";
}
?>

tZ
07-18-2008, 05:54 AM
<form method="post" action="testmailer.php">
<input type="hidden" name="sub" value="1">

<table border="0">


<tr>
<td colspan="6">&nbsp;</td>
</tr>
<tr>
<td colspan="6"><span style="font-weight: bold">What colour do you like?</span></td>
</tr>
<tr>
<td>blue</td>
<td id="checkbox"><input type="checkbox" name="check['color']" value="blue" id="blue" /></td>
<td>red</td>
<td id="checkbox"><input type="checkbox" name="check['color']" value="red" id="red" /></td>
<td id="name">yellow</td>
<td id="checkbox"><input type="checkbox" name="check['color']" value="yellow" id="yellow" /></td>
</tr>


<tr>
<td colspan="6"><span style="font-weight: bold">What size would you like?</span></td>
</tr>
<tr>
<td>large</td>
<td><input type="checkbox" name="check['size']" value="large" id="large" /></td>
<td>medium</td>
<td><input type="checkbox" name="check['size']" value="medium" id="medium" /></td>
<td>small</td>
<td><input type="checkbox" name="check['size']" value="small" id="small" /></td>
</tr>

<tr>
<td colspan="2">&nbsp;</td>
<td colspan="2">&nbsp;</td>
<td colspan="2"><label>
<input name="submit" type="submit" rows="9" value="submit" columns=50 id="submit">
</label></td>
</tr>
</table>
</form>


Without getting into much detail keys needed to be declared for the array values.

I also suggest setting the var $check_msg before using shorthand concentration on it.


************************************************** ****
PHP SIDE
************************************************** ****


<?php
if(isset($_POST['submit'])) {
$to = "rachellegriffin@people.net.au";
$subject = "mailform";

$check_msg='';
foreach($_POST['check'] as $value) {
$check_msg .= "Colour: $value\n";
}

foreach($_POST['check'] as $value) {
$check_msg .= "Size: $value\n";
}

$body = "$colour_msg
$size_msg";


echo "Your inquiry has been successfully submitted.";
mail($to, $subject, $body);
} else {
echo "There was a a problem submitting your form";
}
?>

rlgriffo
07-18-2008, 05:55 AM
thank you so much!! do i leave the PHP the same?