PHP Checkbox email not working -
i php form display radio boxes have been checked. in other words when contacts me via email through website, display radio box ticked. i've tried cannot work!
html code far -
<table width="308" border="0"> <label> <input type="radio" name="servicetype[]" value="checkbox" id="technical support" /> technical support</label> <label> <input type="radio" name="servicetype[]" value="checkbox" id="information services" /> information services</label> <tr> <td align="left"> <input name="submit" type="submit" id="submit" class="contact-class2" value="send"/> </td> </tr> </table> </form>
php far
<?php $field_name = $_post['cf_name']; $field_email = $_post['cf_email']; $field_message = $_post['cf_message']; $mail_to = 'www.example.com'; $subject = 'hello'; $servicetype = join(", ", $_request["servicetype"]); if (isset($_post['servicetype'])) { foreach ($_post['servicetype'] $key => $val) { // need } } $body_message = ''.$field_message."\n"."\n"; $body_message .= 'from: '.$field_name; $headers = 'from: '.$field_email."\r\n"; $headers .= 'reply-to: '.$field_email."\r\n"; $mail_status = mail($mail_to, $subject, $body_message, $headers ); if ($mail_status) { ?> <script language="javascript" type="text/javascript"> window.location = 'contact form.html'; </script> <?php } else { ?> <script language="javascript" type="text/javascript"> window.location = 'contact form.html'; </script> <?php } ?>
you've built checkbox inputs incorrectly. value
attribute should displayed "name" of checkbox, e.g.
<input type="checkbox" name="servicetype[]" value="technical support" id="technical support" /> ^^^^^^^^ ^^^^^^^^^^^^^^^^^
it's value
gets submitted along form. stands now, you'd submitting word "checkbox" , have no way of knowing checkbox(es) selected.
your email be:
$body_message = "blah blah blah. requested services: " . implode(',' $_post['servicetype']);
Comments
Post a Comment