include('Mail.php');
## make sure you got to this page from a link within Walter's site
$pos = strpos($_SERVER['HTTP_REFERER'],"http://www.waltercarl.neu.edu");
if ($_POST['submit']) {
$sender_name = $_POST['visitorname'];
$sender_email = $_POST['visitoremail'];
$message = $_POST['message'];
$allemails = $_POST['friendemails'];
$allnames = $_POST['friendnames'];
if ($pos == 0 && $sender_name
&& $sender_email && $allemails[0] && $allnames[0]) {
$amount = 0;
for($i=0;$i<5;$i++) {
if ($allnames[$i]) {
$return_code = send_email($allnames[$i],$allemails[$i]);
$amount++;
}
}
if ($return_code == 1) {
send_confirm_email($amount);
header("Location: thankyou.htm");
}
}
}
#######################################
function send_confirm_email($amount) {
global $sender_email;
$recipient_email = "w.carl@neu.edu";
$headers['To'] = $recipient_email;
$headers['From'] = $sender_email;
$headers['Subject'] = "Request for Tell-A-Friend";
$params['host'] = "smtp.neu.edu";
$mail_object = &Mail::factory('smtp',$params);
$mailmsg = "$amount friends were referred to your site";
$ok = $mail_object->send($recipient_email,$headers,$mailmsg);
}
#######################################
function send_email($recipient_name,$recipient_email) {
global $sender_name;
global $sender_email;
global $message;
$add_message = "";
if ($message) {
$add_message = "$sender_name also wanted you to know:\n\n$message\n";
}
$mailmsg = << Please complete the following form to refer a friend to this web site. Required fields are your name and email address, and at least one friend's name and email address.
Tell a Friend