bmudd14474 Posted September 24, 2008 Share Posted September 24, 2008 We are using a form to send to a certain person when information or service is requested. We now have the need to use this form in another manor. There will now be 4 options on the form and if a certain option is picked then we want it to be sent to a specific person. So I was thinking a if statement or elseif would work. Then they told me that if multiple boxes are checked that it should go to multiple emails. Am I correct that a if statement will not work in this case? What would I have to use to get this done. I am sure that this is a easy answer but I am just learning PHP. Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/125653-form-question/ Share on other sites More sharing options...
phoenixx Posted September 24, 2008 Share Posted September 24, 2008 Can you post part of your code? It's hard to give an answer w/o seeing part of the code. Quote Link to comment https://forums.phpfreaks.com/topic/125653-form-question/#findComment-649683 Share on other sites More sharing options...
.josh Posted September 24, 2008 Share Posted September 24, 2008 <?php if ($_POST['letter']) { $list = implode(', ',$_POST['letter']); echo $list; } ?> <form action = '' method = 'post'> <input type = 'checkbox' name = 'letter[]' value = 'a'>a <br /> <input type = 'checkbox' name = 'letter[]' value = 'b'>b <br /> <input type = 'checkbox' name = 'letter[]' value = 'c'>c <br /> <input type = 'checkbox' name = 'letter[]' value = 'd'>d <br /> <input type = 'submit' value = 'submit'> </form> Quote Link to comment https://forums.phpfreaks.com/topic/125653-form-question/#findComment-649706 Share on other sites More sharing options...
bmudd14474 Posted September 24, 2008 Author Share Posted September 24, 2008 $emailTo = "[email protected]"; //$emailTo = "[email protected]"; // ESTABLISH THE SUBJECT LINE $subject = "subject"; // ASSEMBLE THE BODY OF THE EMAIL $emailBody = "<b>subject</b><br><br>"; $emailBody .= "<b>Date & Time: </b><font color='blue'>$dateTime</font><br><br>"; $emailBody .= "Name: <font color='blue'>$Name</font><br>"; $emailBody .= "Phone: <font color='blue'>$Phone</font> Ext (if any): <font color='blue'>$PhoneExt</font><br>"; $emailBody .= "Email: <font color='blue'>$Email</font><br>"; $emailBody .= "Address: <font color='blue'>$Address1<br /> $Address2<br /> $City<br /> $State<br /> $ZipCode</font><br>"; $emailBody .= "Services Interested in: <font color='blue'>$Service1<br /> $Service2<br /> $Service3<br /> $Service4</font><br>"; $emailBody .= "<b>Notes/Instructions:</b><br>"; $emailBody .= "<font color='blue'> $notesInstructions</font><br>"; // ASSEMBLE THE EMAIL HEADERS $headers = "From: $Email\r\n"; $headers .= "Reply-To: $Email\r\n"; $headers .= "Return-Path: $Email\r\n"; $headers .= "CC: \r\n"; $headers .= "BCC: \r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; // SEND THE EMAIL if ( mail ($emailTo,$subject,$emailBody,$headers) ) { This is the code that the current webmaster is using. So can I just use the post command to achieve my goal. Again thanks for the help as I am just learning php and trying to help someone else. Quote Link to comment https://forums.phpfreaks.com/topic/125653-form-question/#findComment-649769 Share on other sites More sharing options...
.josh Posted September 24, 2008 Share Posted September 24, 2008 apply my previous post's concept to your $emailTo variable. Quote Link to comment https://forums.phpfreaks.com/topic/125653-form-question/#findComment-649776 Share on other sites More sharing options...
thesaleboat Posted September 24, 2008 Share Posted September 24, 2008 $subject=htmlspecialchars($_POST['subject']); $message=htmlspecialchars($_POST['message']); //see what the subject is to test the game if($subject=="Careers"){ $to = "[email protected]"; } if ($subject=="Business Solutions"){ $to = "[email protected]"; } if ($subject=="Web Administrator"){ $to = "[email protected]"; } if ($subject=="Customer Feedback"){ $to = "[email protected]"; } Quote Link to comment https://forums.phpfreaks.com/topic/125653-form-question/#findComment-649782 Share on other sites More sharing options...
.josh Posted September 24, 2008 Share Posted September 24, 2008 @thesaleboat: First, the OP said he wants to send to multiple people, not just one. 2nd, it would be more efficient to get rid of all those if's and just make the different values the values of the posted var in the first place. Quote Link to comment https://forums.phpfreaks.com/topic/125653-form-question/#findComment-649790 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.