Email based on value in drop down menu

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.

[code]

Test    

[/code]

here is the php code for my formdata page
[php]<?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 “

Your mail was sent successfully”; }
else
{print “

We encountered an error sending your mail”; }

?>[/php]

Sorry forgot to add I am having issues getting the email to work. Regardless of the Text in the form it goes to the first email address listed with all submissions.

I just noticed the issue!

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

had a extra space in it.

So, did that extra space fix it? If not, what is it doing again?

Yes the issue was resolved with the space.

Sponsor our Newsletter | Privacy Policy | Terms of Service