Form Mailer Help<

liunx

Guest
Hello,

I was wondering how to turn my PHP form mailing script into adding additional emails.

Before I explain, here is the code:

(HTML Form)
<form method="post" action="http://nitrox.uni.cc/send.php">
<font color="red">*</font> Your First Name: <br>
<INPUT TYPE="text" NAME="name" SIZE="40" class="form"> <br><br>
Your Email (for response): <br>
<INPUT TYPE="text" NAME="email" SIZE="40" class="form"> <br><br>
<font color="red">*</font> Message: <br>
<TEXTAREA NAME="msg" ROWS=6 COLS=40 class="form"></TEXTAREA><br><br>
<input type=submit class="form" value="Submit">
<input type=reset class="form" value="Reset"><br>
</form>

(Send.php Code)
<?php

$name = $_POST['name'];
$email = $_POST['email'];
$msg = $_POST['msg'];

$name = addslashes(trim($name));
$msg = addslashes(trim($msg));

$sendMail = true;

if(empty($name) || empty($msg)){
$sendMail = false;
}

if ($sendMail) {
$recipient = "(EMAIL)";
$subject = "Nitrox.uni.cc Submission";
$headers = "From: $name\nReply-to: $email\nContent-Type: text/plain\n";

$date = date("Y-m-d, H:i:s");

$message = "Sent by: $name
E-mail: $email
Message: $msg
------
Date of submission: $date
Remote IP: {$_SERVER['REMOTE_ADDR']}\r\n";

mail($recipient,$subject,$message,$headers);
header("Location: thanks.php");
} else {
include('1.php');
echo "<b>Error</b><br>You forgot a field, hit your back button to redo it.";
include('2.php');
}

?>

What I want is, when they view the contact page, at the top of the form there will be a drop down box with two names. If they select Name1 it will go to one email address when the send the email, and if they select Name2, it will send it to a different address. I want them to be able to contact all of my staff there from a drop down.

Can anyone show me how to do this? Thanks!


- Technelwhere is the EMAIL being set?

I would make a normal drop down that contains names and the value is a number, that way you don't get spammed fomr spiders and harvetors.

then in the script you add a check for which one they seelcted.

if($_POST['emailto'] == 1){
$recipient = "(EMAIL)";
}elseif($_POST['emailto'] == 2){
$recipient = "(EMAIL2)";
}


and so on.... or you can do a switch if you want.
 
Back
Top