include('utils.php');
//check the email database for duplicates
//has to be same team and email
function areNoDupes($email,$team) {
$query = "SELECT EMAIL FROM CRUNCHTIME WHERE EMAIL='$email' and ARTIST='$team'";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
$code = $row[0];
if ($code == $email) {
return 0;
}
else {
return 1;
}
}
function insertEmail($email,$team) {
//no dupes, if there are dupes (same exact team and email)
$nodupes = areNoDupes($email,$team);
if ($nodupes == 1) {
$query="INSERT INTO CRUNCHTIME (EMAIL,ARTIST) VALUES ('$email','$team')";
mysql_query($query);
// add them to the email list
// send an intro email
$welcomeMessage="Thank you for joining the $team CRUNCH TIME, you should be receiving an introductory letter soon at $email";
$emailMessage="Welcome to the ticketsnfl.com email newsletter for your favorite team, The $team. We are glad you took the time to join our $team Crunchtime newsletter.
If you have reached this email in error please cut and paste this url into your browser http://www.ticketsnfl.com/remove.php?email=$email&submitme=remove+me!
to remove yourself from the list. Remember, if you need tickets to any event in the U.S. or internationally please call us at 1-800-774-8499 or visit our main
page at www.ticketsnfl.com.
thanks for your interest, Tom";
mail("$email","$email, thank you for joining the ticketsnfl.com $team CRUNCH TIME newsletter",$emailMessage);
header("location:http://www.ticketsnfl.com/newsthanks.html");
}
else {
$errorMessage = "Please correct the form, $email is already subscribed to CRUNCH TIME under $team!";
header("location:http://www.ticketsnfl.com/news.html?errorMessage=$errorMessage&email=$email&team=$team");
}
}
function dispEmailForm() {
global $email;
global $errorMessage;
$title = "CRUNCHTIME newsletter brought to you buy ticketsNFL.com";
$desc = "CRUNCHTIME newsletter sign up football newsletter, nfl newsletter, nfl email, football email, nfl online magazine, nfl e-mail";
$keywords = "nfl news, nfl email newsletter signup, nfl contest, nfl prizes, nfl magazine, nfl online newsletter, nfl online magazine";
$colspan="2";
$header = getHeader($title,$desc,$keywords,$colspan);
echo $header;
echo <<
Enter your email and choose your favorite team to be notified when discounts and special
offers associated with that team are available!
$errorMessage
EOT;
$footer = getFooter($colspan);
echo $footer;
}
if (!isset($B1)) {
dispEmailForm();
}
else {
$result = ereg ("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $email );
if ($result) {
$link=connectDb("Events");
insertEmail($email,$team);
//put the query with the email and team
//select field is called "teams"
mysql_close($link);
}
else {
header("location:http://www.ticketsnfl.com/news.html?errorMessage=ERROR:$email is not a valid email&email=$email");
}
} //main else
?>