Reputation: 1
I am using a sample php conatct form from http://www.html-form-guide.com/contact-form/php-contact-form-tutorial.html and I want to use check box in my form , but I am receiving only last checked one in my email. I find out that I should use array for check boxes like:
input type="checkbox" name="chk_group[]" value="value1" />Value 1<br />
input type="checkbox" name="chk_group[]" value="value2" />Value 2<br />
input type="checkbox" name="chk_group[]" value="value3" />Value 3<br />
and I should use following loop some where in my code:
<?php
if (isset($_POST['chk_group'])) {
$optionArray = $_POST['chk_group'];
for ($i=0; $i'<'count($optionArray); $i++) {
echo $optionArray[$i]."<br />";
}
}
?>
Unfortunately I tried but because the sample contact form which I am using is a little bit strange for me I got errors.
I appreciate if some one can help me to solve this problem. Thanks
Upvotes: 0
Views: 171