group check box in php and send to email -


i using sample php conatct form http://www.html-form-guide.com/contact-form/php-contact-form-tutorial.html , want use check box in form , receiving last checked 1 in email. find out should use array 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 should use following loop in code:

<?php if (isset($_post['chk_group'])) {     $optionarray = $_post['chk_group'];     ($i=0; $i'<'count($optionarray); $i++) {         echo $optionarray[$i]."<br />";     } } ?> 

unfortunately tried because sample contact form using little bit strange me got errors.

i appreciate if 1 can me solve problem. thanks

remove single quotes around <. should be:

for ($i=0; $i<count($optionarray); $i++) { 

you may replace for loop foreach loop:

foreach($optionarray $element) {     echo $element."<br />"; } 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -