#!/usr/bin/perl -w
#-------------------------------------------------------------------------------------------------
# -mail-form.cgi by John Callendar
# -Javascript History/Link from:
# http://www.stickysauce.com/tutorials/programming/javascript/createhistorybutton.htm
#-------------------------------------------------------------------------------------------------
# Modified by:
# L548 - Computer Programming for Information Management - Spring 2003 Project Group
# ACARI Group Members:
# Michelle Cooper - Project Manager
# Matt Devers - Programmer
# Kevin Miller, Jr. - Webmaster
# Created on April 2, 2003
# Modified on August 1, 2003
#-------------------------------------------------------------------------------------------------
# Description:
# -Request Form for the Afghanistan and Central Asia Information website: (mail_form.cgi)
# This program will process all requests for passwords, information,
# and other general information and send the form results via email
# to the Near Eastern Languages and Cultures Department for processing.
# -Request Form must check for:
# 1. Valid Full Name (First and Last Names)
# 2. Valid Email Address (user@domain.com)
#--------------------------------------------------------------------------------------------------
# Contact Information:
# If problems, contact Kevin Miller, Jr., at kevinmillerjr@hotmail.com
#--------------------------------------------------------------------------------------------------
#--------------
# configuration
#--------------
$sendmail = '/usr/sbin/sendmail'; # where is sendmail?
$recipient = 'shahrani@indiana.edu'; # where form data is sent to (will need to be changed to Dr. Shahrani's email address)
$sender = 'nelcmesp@indiana.edu'; # default sender (will need to be changed to NELC email address)
$webmaster = 'kevinmillerjr@hotmail.com'; # webmaster email address
$site_name = 'Afghanistan and Central Asia Research Information'; # name of site to return to after
$site_url = '/~afghan/'; # URL to return to after submitting form
$form = '/~afghan/requestform.htm'; # URL for HTML to Email form
$update = 'August 1, 2003,'; # Last Updated Date for web site
$updateby = 'Kevin Miller, Jr.'; # Person who updated web site
#--------------
# script begins
#--------------
use CGI qw(:standard);
#----------
# get input
#----------
$name = param 'name'; #requester's name
$email = param 'email'; #requester's email address
$request = param 'request'; #requester's request
$comments = param 'comments'; #requester's reason for request
#------------------------
# check for missing input
#------------------------
if ($name eq "") {push(@missing,"Name"); }
if ($email eq "") { push(@missing,"Email"); }
if ($request eq "") { push(@missing,"Reason for Request"); }
$missing= join(", ",@missing); #this will place all missing information in an array and list
#and list in the next part of the program
#------------------------------
# reprompt for input if missing
#------------------------------
if ($missing) {
&htmlopen; #starts the html output page
&htmlbody1;
&htmlbody2a; #prints missing input
&htmlfin;
exit;
}
#------------------------------------------
# Check for bad full name and email address
#------------------------------------------
#----------------------------------
# 1. Check for bad full name format
#----------------------------------
if ($name !~ / /i) {
$badname=1;
$msg1 ="'$name' is not a Valid Full Name.
Please use your First and Last Name.
Example: Bob Hoosier";
}
#--------------------------------
# 2. check for bad address format
#--------------------------------
if ($email !~ /^[^@]+@[^@]+\.[a-zA-Z]{2,4}$/) {
$bademail=1;
$msg2 ="'$email' is not a Valid Email.
Please use this format: user\@domain.com";
}
#---------------------------------------
# 3. print bad fullname and/or bad email
#---------------------------------------
if ($badname||$bademail) {
&htmlopen; #starts the html output page
&htmlbody1;
&htmlbody2b; #prints bad fullname and/or email format
&htmlfin;
exit;
}
#----------------------------------
# END-Check for bad email address
#----------------------------------
#---------------------------------
# set an appropriate From: address
#---------------------------------
if ($email) {
# the user supplied an email address
if ($name) {
$name =~ s/"//g; # lose any double-quotes in name
$sender = "\"$name\" <$email>";
} else {
# user did not supply a name
$sender = "$email";
}
}
#-----------------------
# send the email message
#-----------------------
open MAIL, "|$sendmail -oi -t" or die "Can't open pipe to $sendmail: $!\n";
print MAIL <<"EOP";
To: $recipient
Cc: $webmaster
From: $sender
Subject: ACARI Request Form
Request Form from $name:
Name: $name
Email: $email
Request:
$request
Comments:
$comments
EOP
close MAIL or die "Can't close pipe to $sendmail: $!\n";
#-----------------------------------
# now show the HTML Thank-you screen
#-----------------------------------
&htmlopen; #starts the html output page
&htmlbody1;
&htmlbody2c;
&htmlfin;
#------------
# subroutines
#------------
sub htmlopen
{
print header();
print "";
print "
Incorrect Input$msg1 $msg2 EOP # ## here ends the cell in which the links appear print< |
© Copyright 2002-2003 by the Dept. of Anthropology, Dept. of Central Eurasian Studies, The Department of Near Eastern Languages and Cultures, The Trustees of Indiana University, and M. Nazif Shahrani. Contact Webmaster if you have any questions or problems with this website. |
| Last Updated on $update by $updateby |
Thank you $name for your form submission.
Your Request will be processed shortly.
All responses will be sent to this email address: $email
Name: $name
Email: $email
Request:
$request
Comments:
$comments
EOP # ## here ends the cell in which the links appear print<© Copyright 2002-2003 by the Dept. of Anthropology, Dept. of Central Eurasian Studies, The Department of Near Eastern Languages and Cultures, The Trustees of Indiana University, and M. Nazif Shahrani. Contact Webmaster if you have any questions or problems with this website. |
| Last Updated on $update by $updateby |
EOP } # end sub body1 sub htmlfin { print "