Jump to content

Email based on value in drop down menu


chrispulliam

Recommended Posts

I am having issues with my page. I am trying to send a email to a different address based on the entry that my user submits.

 

Here is my form on my test page.

<form method=POST action=formdata.php>

  <table width="640" border=0 align="center">
    <tr> 
      <td align=right><b>Test</b></td>
      <td><input type=text name=test size=25></td>
      <td> </td>
      <td> </td>
    </tr>
  </table>
  </dl>
  <div align="center">
    <p>
      <input type=hidden name=FA value=SendMail>
    </p>
      <input type=submit value="Submit Form">
    </p>
  </div>
</form>

here is the php code for my formdata page

 


<?php
$con = mysql_connect("localhost","test","test");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("test", $con);

$sql="INSERT INTO formdata (test)
VALUES ('$_POST[test]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "Your Information Was Successfully Posted";

mysql_close($con);

if ($_POST['test'] =="A"){

$to = "[email protected]";
$subject = "Custom Form";
$message = $_POST['test'] ;
$headers = "From: [email protected]";
$sent = mail($to, $subject, $message, $headers) ; 
} else if ($_POST['test'] =="B"){

$to = "[email protected]";
$subject = "Custom Form";
$message = $_POST['test'] ;
$headers = "From: [email protected]";
$sent = mail($to, $subject, $message, $headers) ; 
}
if($sent) 
{print "<p>Your mail was sent successfully"; }
else 
{print "<p>We encountered an error sending your mail"; }



?>

Link to comment
https://forums.phpfreaks.com/topic/259448-email-based-on-value-in-drop-down-menu/
Share on other sites

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.