Menu
I want to create combo box with 3 different emails. When the visitor chooses the option, the email would be sent to that particular email.
Let’s say we have different branches:
1. sales [email][email protected]
2.information [email][email protected]3. careers [email][email protected]
If a visitor chooses sales, the messege would be sent to [email][email protected]
I have a script that sends messege to one e-mail, i am trying to modify it, but i just don’t know from where to start.
Please help me.
I appreciate any help.
Tigerasya
<i>
</i><label>Select department to contact:
<select size="1" name="mailAddr">
<option name="[email protected]">Sales</option>
<option name="[email protected]">Information</option>
<option name="[email protected]">Careers</option>
</select>
</label>
[code=php]
$to = $_POST["mailAddr"];
[/code]
[i]Originally posted by tigerasya [/i]
[B]I want to create combo box with 3 different emails. When the visitor chooses the option, the email would be sent to that particular email.[/B][/QUOTE]
<i>
</i><select name="recipient" size="1">
<option value="[email protected]">Sales</option>
<option value="[email protected]">Information</option>
<option value="[email protected]">Careers</option>
</select>
/* User submitted form
send the message */
case SendMsg:
/* read in info from the form */
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$homepage = $_REQUEST['homepage'];
$message = $_REQUEST['message'];
/* mail it and redirect */
mail($admin_email, "Feedback From "$name [$email]"", $msg, "From: $email");
header("Location: http://www.website.com/feedback.php?req=MsgSent");
break;
/* Print we have
sent the message */
case MsgSent:
MessageSent();
break;
/* No information in $req
print out the form */
default:
ErrMsg();
[code=php]
$admin_email="[email protected]";
[/code]
[code=php]
$admin_email = (isset($_REQUEST["nameOfSelectBox"])||!empty($_REQUEST["nameOfSelectBox"]))?$_REQUEST["nameOfSelectBox"]:"[email protected]";
[/code]
[code=php]
$admin_email = $_POST["mailAddr"];
$admin_email = $admin_email . '@a.com';
[/code]
/* User submitted form
send the message */
case SendMsg:
/* read in info from the form */
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$recipient = $_REQUEST['recipient'];
$homepage = $_REQUEST['homepage'];
$message = $_REQUEST['message'];
/* mail it and redirect */
mail($admin_email, "Feedback From "$name [$email]"", $msg, "From: $email");
header("Location: http://www.website.com/feedback.php?req=MsgSent");
break;
/* Print we have
sent the message */
case MsgSent:
MessageSent();
break;
/* No information in $req
print out the form */
default:
ErrMsg();
[code=php]
<?php
$admin_name="my name";
$admin_email = (isset($_REQUEST["recipient"])&&!empty($_REQUEST["recipient"]))?$_REQUEST["recipient"]:"[email protected]";
if(empty($req)) {
$req='';
}
switch ($req) {
case "SendMsg":
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$homepage = $_REQUEST['homepage'];
$message = $_REQUEST['message'];
if (empty($name) || empty($email) || empty($message)) {
ErrMsg();
}
$msg = "Name: ".$name."nEmail: ".
$email."nHomepage: ".$homepage."nMessage:nn".$message;
mail($admin_email, "Feedback From "$name [$email]"", $msg, "From: $email");
header("Location: http://www.website.com/feedback.php?req=MsgSent");
break;
case "MsgSent":
MessageSent();
break;
default:
ErrMsg();
}
function ErrMsg() {
include("error.html");
}
function MessageSent() {
include("thankyou.html");
}
?>
[/code]
[code=php]
<html>
<head>
<title>Contact us</title>
<link rel="stylesheet" href="Stylesheet.css" type="text/css">
</head>
<body>
<form method="post" action="correspondence_confirm.php">
<table>
<tr>
<td>First Name:
</td>
<td><input name="fname">
</td>
</tr>
<tr>
<td>Surname:
</td>
<td><input name="surname">
</td>
</tr>
<tr>
<td>Phone:
</td>
<td><input name="phone">
</td>
</tr>
<tr>
<td>Fax:
</td>
<td><input name="fax">
</td>
</tr>
<tr>
<td>Email:
</td>
<td><input name="email" size="66">
</td>
</tr>
<tr>
<td>Company Name:
</td>
<td><input name="busname">
</td>
</tr>
<tr>
<td>Subject:
</td>
<td><input name="subject">
</td>
</tr>
<tr>
<td>Attention:
</td>
<td><input type="radio" name="attention" value="Manager">Manager<br/>
<input type="radio" name="attention" value="Aboriginal Enterprise Development Officer">Aboriginal Enterprise Development Officer<br />
</td>
</tr>
</table>
<p>Message:</p>
<textarea name="message" cols="64" rows="20"></textarea><br />
<input type="reset" value="Reset">
<input type="submit" value="Send">
</form>
</body>
</html>[/code]
[code=php]<html>
<head>
<title>
Please confirm the information is correct
</title>
</head>
<body>
<h1>Please confirm this message</h1>
<p><?php
echo "<b>First Name:</b> $fname <br />";
echo "<b>Surname:</b> $surname<br />";
echo "<b>Phone:</b> $phone<br />";
echo "<b>Fax:</b> $fax<br />";
echo "<b>Email:</b> $email<br />";
echo "<b>Company Name:</b> $busname<br />";
echo "<b>Subject:</b> $subject<br />";
echo "<b>Attention:</b> $attention<br />";
echo "<b>Message:</b> $message<br />";
?>
</p>
<table>
<tr>
<td>
<form method="post" action="correspondence_submited.php">
<input type="hidden" name="fname_second" value="<?php echo $fname;?>">
<input type="hidden" name="surname_second" value="<?php echo $surname;?>">
<input type="hidden" name="phone_second" value="<?php echo $phone;?>">
<input type="hidden" name="fax_second" value="<?php echo $fax;?>">
<input type="hidden" name="email_second" value="<?php echo $email;?>">
<input type="hidden" name="busname_second" value="<?php echo $busname;?>">
<input type="hidden" name="subject_second" value="<?php echo $subject;?>">
<input type="hidden" name="attention_second" value="<?php echo $attention;?>">
<input type="hidden" name="message_second" value="<?php echo $message;?>">
<input type="submit" value="Send">
</form>
</td>
<td>
<form method="post" action="contact_us_edit.php">
<input type="hidden" name="fname_second" value="<?php echo $fname;?>">
<input type="hidden" name="surname_second" value="<?php echo $surname;?>">
<input type="hidden" name="phone_second" value="<?php echo $phone;?>">
<input type="hidden" name="fax_second" value="<?php echo $fax;?>">
<input type="hidden" name="email_second" value="<?php echo $email;?>">
<input type="hidden" name="busname_second" value="<?php echo $busname;?>">
<input type="hidden" name="subject_second" value="<?php echo $subject;?>">
<input type="hidden" name="attention_second" value="<?php echo $attention;?>">
<input type="hidden" name="message_second" value="<?php echo $message;?>">
<input type="submit" value="Edit">
</form>
</td>
</tr>
</table>
</body>
</html>[/code]
[code=php]<?php
if ($attention_second=='Manager') {
$toaddress = "Email removed";
} else if ($attention_second=='Aboriginal Enterprise Development Officer') {
$toaddress = "Email removed";
}
$mailcontent = "Client Name: ".$fname_second." ".$surname_second."rn
Phone: ".$phone_second."rn
Fax: ".$fax_second."rn
Email: ".$email_second."rn
Company Name: ".$busname_second."rn
Clients message: "."rn".$message_second;
mail($toaddress, $subject_second, $mailcontent);
?>
<html>
<head>
<title>
Message has been sent.
</title>
</head>
<body>
<h1>This message has been sent.</h1>
<?php
echo "<b>First name:</b> $fname_second<br />";
echo "<b>Surname:</b> $surname_second<br />";
echo "<b>Phone:</b> $phone_second<br />";
echo "<b>Fax:</b> $fax_second<br />";
echo "<b>Fax:</b> $email_second<br />";
echo "<b>Fax:</b> $busname_second<br />";
echo "<b>Attention:</b> $attention_second<br />";
echo "<b>to address:</b> $toaddress<br />";
echo "<b>Subject:</b> $subject_second<br />";
echo "<b>message:</b> $message_second<br />";
?>
</body>
</html>[/code]
[code=php]if ($attention_second=='Manager') {
$toaddress = "Email removed";
} else if ($attention_second=='Aboriginal Enterprise Development Officer') {
$toaddress = "Email removed";
}[/code]
0.1.9 — BETA 5.16