include ("header.php");
extract($_REQUEST);
if ($submit) {
// check if e-mail is address is valid
if ($usermail){
if (eregi ("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]+$", $usermail)) {
list ($userName, $mailDomain) = split("@", $usermail);
if (!checkdnsrr($mailDomain, "MX")){$usermail='';}
}
else {$usermail='';}
// see if e-mail is already in the database
$chckemailDB = mysql_query("SELECT * FROM mail_list WHERE e_mail ='$usermail'");
if (mysql_num_rows($chckemailDB) > 0){
$mailexist='TRUE';
$usermail='';}
}
// make sure REQUIRED values have been filled in
// To add more requirements uncomment the fields below:
if ($firstname == ''
|| $lastname == ''
|| $usermail == ''
// || $cityname == ''
// || $statename == ''
// || $countryname == ''
// || $organization == ''
// || $orgtype == ''
) {
$errors = "true";
}
// REMOVE WHITESPACE AND ENTER INTO DATABASE
else {
$alldone = "TRUE";
$firstname = trim($firstname);
$lastname = trim($lastname);
$usermail = trim($usermail);
$usermail = strtolower($usermail);
$cityname = trim($cityname);
$organization = trim($organization);
$sql = "INSERT INTO mail_list (usrID, first_name, last_name, e_mail, city, state, country,
organization, org_type) VALUES ('','$firstname', '$lastname',
'$usermail', '$cityname', '$statename', '$countryname',
'$organization', '$orgtype')";
$result = mysql_query($sql);
}
}
print "
";
if ($alldone){
//--SEND MAIL
$tgl = date("F d, Y - h:i A");
$msgtitle = "Welcome to VIPER";
$msgcontent = "Local time : $tgl\n\nYou have successfully been added to the VIPER mailing list!\nYou will now be the first to receive any updates on new Viral Coordinates, Analysis Tools, and other Virus-related news!\n If you ever wish to stop receiving mailings from VIPER, send an e-mail to viper at scripps.edu with the subject heading 'unsubscribe'.\n\nWelcome to the VIPER Community!\n";
mail($usermail,$msgtitle,$msgcontent,"From: viper@scripps.edu\n");
// print page:
print "Thank you for taking the time to subscribe to the VIPER mailing list. \n";
print "You will receive an e-mail shortly informing you of your subscription. \n";
print "You have submitted the following information: \n";
print "Name: $firstname $lastname \n";
print "E-mail: $usermail \n";
print "Location: $cityname, $statename \n";
print "Country: $countryname \n";
print "Organization: $organization ($orgtype) \n";
print " BACK TO VIPER HOME\n";
}
else {
if ($errors == 'true') {
print "
We're sorry, we could not subscribe you to our
mailing list due to the following errors: \n
";
if ($firstname == ''){print "
You did not specify your first name. \n";}
if ($lastname == ''){print "
You did not specify your last name. \n";}
if ($usermail == '') {
if ($mailexist) {
print "
The e-mail address you specified is already in our
database, Please use a new address. \n";
$mailexists='';
}
else {
print "
You did not specify a valid e-mail address. \n";
print "(e.g., hello@myworld.com) \n" ;
}
}
// if ($cityname == ''){print "
You did not specify a city. \n";}
// if ($statename == ''){print "
You did not specify a state -
// NOTE: If the state/providence section is not applicable, select \"Not
// Applicable\" from the bottom of the list.\n";}
// if ($countryname == ''){print "
You did not specify a country. \n";}
// if ($organization == ''){print "
You did not specify the organization to which you belong. \n";}
// if ($orgtype == ''){print "
You did not specify an organization type. \n";}
print "
\n \nPlease take the time to complete your submission: \n";
print " \n";
print "
\n";
}
else {
print"
Sign up to receive news concerning VIPER updates
We respect your privacy!
Your name and e-mail address will NOT be shared with any third
party. At the bottom of every e-mail you receive from VIPER you will
have the opportunity to delete yourself from our mailing list and
prevent any further mailings.