August 7th, 2006, 01:17 PM
|
#1 (permalink)
|
| Ultimate Member
Join Date: Oct 2001
Posts: 2,309
| [PHP] Creating "if" Statement for Email Form
Hello! I have an e-mail form which takes the submitted form and sends an e-mail with it.
The code is below: Code: <?php
ini_set("SMTP","localhost");
ini_set("smtp_port","25");
ini_set("sendmail_from","fromaddy");
if(isset($_POST['submit'])) {
$to = "toaddy";
$subject = $_POST['name'] . ': ' . $_POST['drop_down'];
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$body = "From: $name_field\nE-Mail: $email_field\nMessage:\n$message\n";
echo "Your message has been sent! <br> <a href=\"http://www.waupunpubliclibrary.org/contactus.php\">Click Here to Go Back</a> ";
mail($to, $subject, $body);
} else {
echo "Error: What are you doing?";
}
?>
How would I add an "if" statement in this (I think that's what it's called), so that if the 'drop_down' field equals some specific string, it sets the $to address to something else?
Thank you!
Cody |
| |