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@sample.com";
$subject = "Custom Form";
$message = $_POST['test'] ;
$headers = "From: email@sample.com";
$sent = mail($to, $subject, $message, $headers) ; 
} else if ($_POST['test'] =="B"){

$to = "email2@sample.com";
$subject = "Custom Form";
$message = $_POST['test'] ;
$headers = "From: email@sample.com";
$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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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