Jump to content

PHP code to email selected options in database


vikela

Recommended Posts

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..

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.