View Full Version : Mail Script Help
GhettoT
12-13-2006, 08:26 PM
How do I make a PHP script so that there is a drop down menu with a list of names. Depending on the name/selection that the user selects it will send the e-mail to a different person. Also, how do I make it so that the form has a spot for a subject that the user can input?
For the subject I would like the subject in the e-mail to actually appear as "[Site Contact Us]_USER_SUBMITTED_SUBJECT_" Are either of these even possible?
-GT
boxxertrumps
12-13-2006, 10:22 PM
we'll need your code to modify it for you.
thetestingsite
12-13-2006, 11:30 PM
Use the following codes as an example, and edit to your liking.
test.html
<html>
<head>
<title>Contact Us</title>
</head>
<body>
<form action="mailer.php" method="POST">
<input type="hidden" name="act" value="mail_it">
Your Name: <input type="text" name="name"> <BR>
Your Email: <input type="text" name="email"> <BR>
Subject: <input type="text" name="subject"> <BR>
Who do you wish to contact?<BR>
<select name="mailto">
<option value="">-- Choose One --</option>
<option value="john">John Smith</option>
<option value="ashley">Ashley M.</option>
<option value="accounting">Accounting</option>
</select>
<BR>
Message: <textarea cols="30" rows="10" name="message"></textarea>
<BR>
<input type="submit" value="Send Message">
</body>
</html>
mailer.php
<?php
$site = "http://mydomain.com/contact.php"; //your website url to redirect to
/* Edit the following array! Be sure to keep the format
'select option name' => 'select option email address'
Ex: 'john' => 'john@mydomain.com', ...*/
$to = array(
'john' => 'john@mydomain.com',
'ashley' => 'ashley@mydomain.com',
'accounting' => 'accounting@mydomain.com'
);
/*no need to edit below this*/
$name = $_REQUEST[name];
$email = $_REQUEST[email];
$mailto = $_REQUEST[mailto];
$subject = $_REQUEST[subject];
$message = $_REQUEST[message];
$act = $_REQUEST[act];
if ($act == "mail_it") {
$sendto = $to[$mailto];
$sub = '[Site Contact Us]_'.$subject;
$send = mail($sendto, $sub, $message);
if ($send) {
header('Refresh: 2; url='.$site);
echo 'Your message was sent successfully and you will recieve a response ASAP!';
}
else {
header('Refresh: 2; url='.$site);
echo 'Your message was not sent! Please try again.';
}
}
else {
header('Location: '.$site); //redirects user back to your website
}
?>
I haven't tested it out, but it should work. Let me know if you need any more help.
thetestingsite
12-15-2006, 08:29 PM
Ok, the above code that I posted has been tested and it works fine. Let me know if you experience any problems with it, or if you need any more help on this matter.
GhettoT
12-16-2006, 01:28 AM
Alright, thanks! I have not been able to add it to my site yet, because the other guy in my web team hasn't registered on the host yet. But I will definately notify you if something doesn't work!
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.