hi guys, need your help on this..any ideas is greatly appreciated..i got this form mailer from this site:

but how to configure in php the form mailer that if in my form got two options (like the code below) that if the user choose this particular option then it will go to that particular e-mail.

So basically, got two options on the site but will have two e-mails also but not both of them will receive the mail, when the user press the submit button then it will go only to that particular mail in which the user selected.

please help...

but this one works if data is sent to one e-mail
here's the code on my form:

<form name="form1" method="post" action="formmail.php">
              <table width="90%"  border="0" cellspacing="0" cellpadding="3">
                  <th width="42%" valign="middle" scope="row"><div align="right"> Type </div></th>
                  <td width="58%"><select name="Appt_Type" size="1" class="entries">
                    <option value="Karate">Karate</option>
                    <option value="Judo">Judo</option>
                    <label></label>                  </td>
                  <th valign="middle" scope="row"><div align="right">Preferred Schedule Date </div></th>
                  <td><input name="P_Date" type="text" class="entries" id="P_Date"></td>
                  <th valign="middle" scope="row"><div align="right">Preferred Schedule Time </div></th>
                  <td><input name="P_Time" type="text" class="entries" id="P_Time"></td>
                  <th valign="middle" scope="row"><div align="right">Preferred Location </div></th>
                  <td><select name="Location" class="entries" id="Location">

                    <option value="Kar_Vill">The Karate Village</option> 'problem here if the user choose this
                                                                         'then it will go to preferred e-mail
                    <option value="Judo_Mount">The Judo Mountain</option>'if the user choose this option
                                    </select></td>                       'then will go to particular e-mail  
                  <th valign="middle" scope="row"><div align="right">Name</div></th>
                  <td><input name="Name" type="text" class="entries" id="Name"></td>
                  <th valign="middle" scope="row"><div align="right">Tel</div></th>
                  <td><input name="Tel" type="text" class="entries" id="Tel"></td>
                  <th valign="middle" scope="row"><div align="right">Email</div></th>
                  <td><input name="Email" type="text" class="entries" id="Email"></td>
                  <th valign="middle" scope="row"><div align="right">Member No. </div></th>
                  <td><input name="Mem_No" type="text" class="entries" id="Mem_No"></td>
                  <th valign="middle" scope="row"><div align="right"></div></th>
                  <td><input name="Submit" type="submit" class="entries" value="Book Now">
                      <input name="Reset" type="reset" class="entries" value="Reset">
                      <input type="hidden" name="subject" value="The Karate_Appt" />

                      <input type="hidden" name="recipient" value="karate@karatexyz.com.ph" /> 'problem here I want to put another e-mail
                                                                                               'depending on what option the user choose
                                                                                               'from above selection

                      <input type="hidden" name="required" value="Appt_Type,Pref_Date,Pref_Time,Location,Name,Tel,Email" />
                      <input type="hidden" name="missing_fields_redirect" value="http://www.masterxyz.com/error.html" />
                      <input type="hidden" name="redirect" value="http://www.masterxyz.com/thankyou.html" /></td>

getting the form's data is done by a function by php on the form mailer that i found on the link given above..

can anyone help on how to do if there's two e-mail on the form..
below is the php code of the form's mailer to get the data..


// This function takes the sorts, excludes certain keys and 
// makes a pretty content string.
function parse_form($array, $sort = "") {
   // build reserved keyword array
   $reserved_keys[] = "MAX_FILE_SIZE";
   $reserved_keys[] = "required";
   $reserved_keys[] = "redirect";
   $reserved_keys[] = "require";
   $reserved_keys[] = "path_to_file";
   $reserved_keys[] = "recipient";
   $reserved_keys[] = "subject";
   $reserved_keys[] = "sort";
   $reserved_keys[] = "style_sheet";
   $reserved_keys[] = "bgcolor";
   $reserved_keys[] = "text_color";
   $reserved_keys[] = "link_color";
   $reserved_keys[] = "vlink_color";
   $reserved_keys[] = "alink_color";
   $reserved_keys[] = "title";
   $reserved_keys[] = "missing_fields_redirect";
   $reserved_keys[] = "env_report";
   $reserved_keys[] = "submit";
   if (count($array)) {
      if (is_array($sort)) {
         foreach ($sort as $field) {
            $reserved_violation = 0;
            for ($ri=0; $ri<count($reserved_keys); $ri++)
               if ($array[$field] == $reserved_keys[$ri]) $reserved_violation = 1;

            if ($reserved_violation != 1) {
               if (is_array($array[$field])) {
                  for ($z=0;$z<count($array[$field]);$z++)
                     $content .= $field.SEPARATOR.$array[$field][$z].NEWLINE;
               } else
                  $content .= $field.SEPARATOR.$array[$field].NEWLINE;
      while (list($key, $val) = each($array)) {
         $reserved_violation = 0;
         for ($ri=0; $ri<count($reserved_keys); $ri++)
            if ($key == $reserved_keys[$ri]) $reserved_violation = 1;

         for ($ri=0; $ri<count($sort); $ri++)
            if ($key == $sort[$ri]) $reserved_violation = 1;

         // prepare content
         if ($reserved_violation != 1) {
            if (is_array($val)) {
               for ($z=0;$z<count($val);$z++)
                  $content .= $key.SEPARATOR.$val[$z].NEWLINE;
            } else
               $content .= $key.SEPARATOR.$val.NEWLINE;
   return $content;

// mail the content we figure out in the following steps
function mail_it($content, $subject, $email, $recipient) {
   global $attachment_chunk, $attachment_name, $attachment_type, $attachment_sent, $bcc;

   $ob = "----=_OuterBoundary_000";
   $ib = "----=_InnerBoundery_001";
   $headers  = "MIME-Version: 1.0\r\n"; 
   $headers .= "From: ".$email."\n"; 
   $headers .= "To: ".$recipient."\n"; 
   $headers .= "Reply-To: ".$email."\n";
   if ($bcc) $headers .= "Bcc: ".$bcc."\n"; 
   $headers .= "X-Priority: 1\n"; 
   $headers .= "X-Mailer: DT Formmail".VERSION."\n"; 
   $headers .= "Content-Type: multipart/mixed;\n\tboundary=\"".$ob."\"\n";
   $message  = "This is a multi-part message in MIME format.\n";
   $message .= "\n--".$ob."\n";
   $message .= "Content-Type: multipart/alternative;\n\tboundary=\"".$ib."\"\n\n";
   $message .= "\n--".$ib."\n";
   $message .= "Content-Type: text/plain;\n\tcharset=\"iso-8859-1\"\n";
   $message .= "Content-Transfer-Encoding: quoted-printable\n\n";
   $message .= $content."\n\n";
   $message .= "\n--".$ib."--\n";
   if ($attachment_name && !$attachment_sent) {
      $message .= "\n--".$ob."\n";
      $message .= "Content-Type: $attachment_type;\n\tname=\"".$attachment_name."\"\n";
      $message .= "Content-Transfer-Encoding: base64\n";
      $message .= "Content-Disposition: attachment;\n\tfilename=\"".$attachment_name."\"\n\n";
      $message .= $attachment_chunk;
      $message .= "\n\n";
      $attachment_sent = 1;
   $message .= "\n--".$ob."--\n";
   mail($recipient, $subject, $message, $headers);
Votes + Comments
8 Years
Discussion Span
Last Post by cguan_77

I cannot see a call to the mail_it function in the code you posted, but what you will need to do is change the $recipient value that is being sent to the mail_it function depending on which option is selected.

Votes + Comments
thank you :)

thanks Will..the mail_it function is there..i just made changes on that function as you suggested... Thanks a bunch... :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.