Kathy Posted July 10, 2009 Share Posted July 10, 2009 I'm currently using this code $to = 'person@domain.co.za'; $from = $email; $subject = 'Online Registration'; $message = '<body style="font-family:tahoma; font-size:12px; line-height:18px; color:#333366">'. $initials.', '.$surname.', '.$company_name.', '.$address.', '.$address2.', '.$address3.', '.$telephone.', '.$email.', '.$method.', '.$type.', '.$JobFunction. $Reference .'</body>'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'FROM: '. $from . "\r\n"; mail($to, $subject, $message, $headers); to send an email from a file to myself containing filled in information from a form, note that $JobFunction can be a choice of 13 checkboxes. See code below: if(isset($_POST["ch1"])){ $checkbox1 = $_POST["ch1"] . ", "; } if(isset($_POST["ch2"])){ $checkbox2 = $_POST["ch2"] . ", "; } if(isset($_POST["ch3"])){ $checkbox3 = $_POST["ch3"] . ", "; } if(isset($_POST["ch4"])){ $checkbox4 = $_POST["ch4"] . ", "; } if(isset($_POST["ch5"])){ $checkbox5 = $_POST["ch5"] . ", "; } if(isset($_POST["ch6"])){ $checkbox6 = $_POST["ch6"] . ", "; } if(isset($_POST["ch7"])){ $checkbox7 = $_POST["ch7"] . ", "; } if(isset($_POST["ch8"])){ $checkbox8 = $_POST["ch8"] . ", "; } if(isset($_POST["ch9"])){ $checkbox9 = $_POST["ch9"] . ", "; } if(isset($_POST["ch10"])){ $checkbox10 = $_POST["ch10"] . ", "; } if(isset($_POST["ch11"])){ $checkbox11 = $_POST["ch11"] . ", "; } if(isset($_POST["ch12"])){ $checkbox12 = $_POST["ch12"] . ", "; } if(isset($_POST["ch13"])){ $checkbox13 = $_POST["ch13"] . ", "; } $JobFunction = $checkbox1 . $checkbox2 . $checkbox3 . $checkbox4 . $checkbox5 . $checkbox6 . $checkbox7 . $checkbox8 . $checkbox9 . $checkbox10 . $checkbox11 . $checkbox12 . $checkbox13; I would like to change this to a 1 and 0 system, when somebody selects the checkbox it should display as 1, if not, it should display as 0, I cannot get this to work though and have tried to include my radio buttons into this system. $msgheading = "Visitor Registration from website"; $msg = $initials . ","; $msg .= $surname . ","; $msg .= $company . ","; $msg .= $postal . ","; $msg .= $city . ","; $msg .= $code . ","; $msg .= $tel . ","; $msg .= $email . ","; if ($business == 1) { $msg .= "1,0,0,0,"; } if ($business == 2) { $msg .= "0,1,0,0,"; } if ($business == 3) { $msg .= "0,0,1,0,"; } if ($business == 4) { $msg .= "0,0,0,1,"; } if ($owner <> '') { $msg .= "1,"; } else { $msg .= "0,"; } if ($finance <> '') { $msg .= "1,"; } else { $msg .= "0,"; } if ($human <> '') { $msg .= "1,"; } else { $msg .= "0,"; } if ($marketing <> '') { $msg .= "1,"; } else { $msg .= "0,"; } if ($farm <> '') { $msg .= "1,"; } else { $msg .= "0,"; } if ($research <> '') { $msg .= "1,"; } else { $msg .= "0,"; } if ($information <> '') { $msg .= "1,"; } else { $msg .= "0,"; } if ($vitic <> '') { $msg .= "1,"; } else { $msg .= "0,"; } if ($wine <> '') { $msg .= "1,"; } else { $msg .= "0,"; } if ($hospitality <> '') { $msg .= "1,"; } else { $msg .= "0,"; } if ($buying <> '') { $msg .= "1,"; } else { $msg .= "0,"; } if ($other <> '') { $msg .= "1"; } else { $msg .= "0"; } $sendto = "person@domain.co.za"; mail($sendto , $msgheading , $msg , "From: Website"); I can't get it to work though, any suggestions?? Quote Link to comment https://forums.phpfreaks.com/topic/165471-php-mail/ Share on other sites More sharing options...
ignace Posted July 10, 2009 Share Posted July 10, 2009 note that $JobFunction can be a choice of 13 checkboxes modify your checkboxes name to: <input type="checkbox" name="ch[]" value="jobfunction1"> <input type="checkbox" name="ch[]" value="jobfunction2"> <input type="checkbox" name="ch[]" value="jobfunction3"> <input type="checkbox" name="ch[]" value="jobfunct..."> Then in your php you can do: $JobFunction = implode(', ', $_POST['ch']); // jobfunction1, jobfunction2, ..., jobfunction13 (no trailing ,) The same goes for $business, $owner, $human, .. Assume a common name: occupation Business: <input type="radio" name="occupation[]" value="1"><!-- if checked then the value=1, null otherwise --> Owner: <input type="radio" name="occupation[]" value="1"> Human: <input type="radio" name="occupation[]" value="1"> <?php $occupation = $_POST['occupation']; //array('1', '', '', '1', '', '', '', '1', ..); array_walk($occupation, 'set_bool'); $occupation = implode(', ', $occupation); // 1,0,0,1,0,0,0,1, .. function set_bool(&$item, $key) { $item = !empty($item) ? 1 : 0; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/165471-php-mail/#findComment-872736 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.