How can I make it to where you can select from a dropdown list and have it go to different e-mails
![]() |
How can I make it to where you can select from a dropdown list and have it go to different e-mails
Time to dust off the old Form processing script!
For the sake of my sanity, I am going to assume (In other words, make an of you and me) that you already know how to make HTML forms and PHP scripts to process them. This is the code that needs to go into your HTML File:
In the PHP Script, you just 'trim' it like you would any other form variable:Code:<select name = "EmailTo">
<option value = "[email protected]">[email protected]</option>
<option value = "[email protected]">[email protected]</option>
<option value = "[email protected]">[email protected]</option>
</select>
All in all, this is a complete overview of my Source code for a simple email script:Code:$EmailTo = Trim(stripslashes($_POST['EmailTo']));
index.htm
Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/transitional.dtd">
<head>
<title>Example Email Form</title>
<link href="style.css" rel = "stylesheet" type = "text/css">
</head>
<body>
<form method="POST" action="post.php">
<h1>Example Email Form</h1>
<p>Recipiant Email Address:</p>
<select name = "EmailTo">
<option value = "[email protected]">[email protected]</option>
<option value = "[email protected]">[email protected]</option>
<option value = "[email protected]">[email protected]</option>
</select>
<br>
<p>Subject: <input type="text" name="subj"></p>
<p>Message:</p>
<textarea name = "msg" rows = "20" cols = "40">Enter Message Here</textarea>
<p><input type="submit" name="submit" value="Submit"></p>
<br><br><br><br>
</form>
post.php
I have also uploaded the script to my webserver. The email function has been dissabled, but this will show you what it looks like: http://jthomsonmain.server1.cc/dev/examp/mail/mail.htmCode:<?php
$EmailFrom = "[email protected]";
$EmailTo = Trim(stripslashes($_POST['EmailTo']));
$Subject = Trim(stripslashes($_POST['subj']));
$Message = Trim(stripslashes($_POST['msg']));
$Body = "";
$Body .= $Message;
$Body .= "\n";
$Success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
if ($Success)
{
echo "Form Submited";
}
else
{
echo "ERROR: UNKNOWN";
}
?>
All times are GMT -7. The time now is 07:41 AM. |