vikela Posted March 5, 2009 Share Posted March 5, 2009 hi m new to PHP m trying to create a code that can email users in my database based on gender(male/female),region etc.i would like to have a pull down on a form to select the criteria then based on that i would like to send an email.i can understand the mail(function) Link to comment https://forums.phpfreaks.com/topic/148077-php-code-to-email-selected-options-in-database/ Share on other sites More sharing options...
WolfRage Posted March 5, 2009 Share Posted March 5, 2009 You can or can't understand the mail(); function? Link to comment https://forums.phpfreaks.com/topic/148077-php-code-to-email-selected-options-in-database/#findComment-777260 Share on other sites More sharing options...
Stephen68 Posted March 5, 2009 Share Posted March 5, 2009 Ya you have the right idea, just make your form with the drop downs you want for who to send to. Then when you submit the form use the form info. to search the fields in you DB and get the email addresses from that search. Once you have all the addresses you just use the mail function to send it to them. I'm not sure about the mail() does it allow you to have multi address? if so just implode() it and add to mail() in the right spot. Hope this is what you are thinking on, if not maybe tell us some more.. Link to comment https://forums.phpfreaks.com/topic/148077-php-code-to-email-selected-options-in-database/#findComment-777314 Share on other sites More sharing options...
vikela Posted March 5, 2009 Author Share Posted March 5, 2009 thanxs i will try to use the implode().but whats wrong with this code<?php include('dashConfig.php'); ?> <style type="text/css"> <!-- .style1 { font: bold 24px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #0000CC; } --> </style> <p align="center" class="style1">Moderator Outbound </p> <?php if ($_SERVER['REQUEST_METHOD'] != 'POST'){ $me = $_SERVER['PHP_SELF']; ?> <form name="form1" method="post" action="<?php echo $me;?>"> <table width="1177" border="0" align="center"> <tr> <th width="323" nowrap scope="col">Select Respondents: <select name="mychoice"> <option value="Male" selected>Male</option> <option value="Female">Female</option> <option value="All">All</option> </select> </th> <th width="454" nowrap scope="col">Select Mode: <select name="select2"> <option value="SMS">SMS</option> <option value="MMS">MMS</option> <option value="E-Mail">E-Mail</option> <option value="Voice(IVR)">Voice(IVR)</option> </select> </th> <th width="386" align="left" nowrap scope="col">Select Auto Event Follow-up: <select name="select3"> <option value="SMS">SMS</option> <option value="MMS">MMS</option> <option value="E-Mail">E-Mail</option> <option value="Voice(IVR)">Voice(IVR)</option> </select></th> </tr> <tr> <td rowspan="3"> </td> <td align="center" nowrap><p><strong>Subject:</strong> <input name="subject" type="text" id="subject" size="35"> </p> </td> <td rowspan="3" align="center"><input type="submit" name="Submit2" value="ADD CONTENT"></td> </tr> <tr> <td align="center" nowrap><strong>From: <input name="moderator" type="text" id="from" size="35"> </strong></td> </tr> <tr> <td align="center"><textarea name="MsgBody" cols="50" rows="5"></textarea></td> </tr> <tr> <td> </td> <td align="center"><input type="submit" name="Submit" value="ADD CONTENT"></td> <td> </td> </tr> </table> <div align="center"></div> </form> <?php } else { error_reporting(0); switch($_POST['color']){ case 'Male': $recipient = mysql_query("SELECT email FROM PanelMember WHERE gender=m"); break; case 'female': $recipient = mysql_query("SELECT email FROM PanelMember WHERE gender=f"); break; default: $recipient = mysql_query("SELECT email FROM PanelMember"); } $subject = stripslashes($_POST['Subject']); $from = stripslashes($_POST['moderator']); $msg = "Message from: $from\n\n".stripslashes($_POST['MsgBody']); if (mail($recipient, $subject, $msg)) echo nl2br("<b>Message Sent:</b> To: $recipient Subject: $subject Message: $msg"); else echo "Message failed to send"; } ?> <p> </p> Link to comment https://forums.phpfreaks.com/topic/148077-php-code-to-email-selected-options-in-database/#findComment-777378 Share on other sites More sharing options...
WolfRage Posted March 7, 2009 Share Posted March 7, 2009 Well just from a quick look at your code, this is a problem. <?php $_POST['color'] Should be: $_POST['mychoice'] ?> Link to comment https://forums.phpfreaks.com/topic/148077-php-code-to-email-selected-options-in-database/#findComment-778957 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.