122 lines
3.0 KiB
PHP
122 lines
3.0 KiB
PHP
<html>
|
|
<head>
|
|
<style type="text/css">
|
|
body {
|
|
/*background-image: url(http://www.sheffieldresources.com/graphics/bg.jpg);*/
|
|
font-family: Tahoma, Arial;
|
|
font-size: 10px;
|
|
}
|
|
p {
|
|
font-family: Tahoma, Arial;
|
|
font-size: 12px;
|
|
}
|
|
h2 {
|
|
font-family: Tahoma, Arial;
|
|
font-size: 14px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<p><br></p>
|
|
<center>
|
|
<table width='600' cellpadding='15' cellspacing='0' border='0'>
|
|
<tr height='400'>
|
|
<td bgcolor='#ffffff' align='center'>
|
|
|
|
<?php
|
|
// unsubscribe.php
|
|
// called from footer in email mail.footer.php
|
|
// variables record_num and email
|
|
|
|
// include files
|
|
include "phpdir.php";
|
|
include "db.php";
|
|
|
|
// normally thew below line is only needed
|
|
//$DOMAIN = $current_domain_name;
|
|
$DOMAIN_T = "sales.invancouver.com";
|
|
$DOMAIN = "invancouver.com";
|
|
|
|
$FOOTER = " </td>\n </tr>\n </table>\n</center>\n</body>\n</html>\n";
|
|
|
|
|
|
// Initial screen message
|
|
echo("<h2>$DOMAIN_T Email Database Unsubscribe</h2>\n");
|
|
|
|
// set error messages
|
|
$missing_info_error = "<p>Sorry. We are unable to unsubscribe you from our list at " .
|
|
"this time.<br>" .
|
|
"Please contact <a href=\"mailto:info@$DOMAIN\">info@$DOMAIN</a> " .
|
|
"for assistance.</p>";
|
|
|
|
$error1 = "<p>Sorry. You are not currently subscribed to our list <br>" .
|
|
"Please contact <a href=\"mailto:info@$DOMAIN\">info@$DOMAIN</a> " .
|
|
"for assistance.</p>";
|
|
|
|
$invite = "<p>You are welcome to join our mailing list " .
|
|
"by subscribing <a href=\"http://www.$DOMAIN\">on our website</a> " .
|
|
"</p>";
|
|
|
|
|
|
// error message if confirm record_num and emails are false
|
|
if (!$email && !record_num){
|
|
echo("$missing_info_error");
|
|
echo("$invite\n");
|
|
echo($FOOTER);
|
|
return;
|
|
}
|
|
|
|
// open table emails
|
|
$TableName = "contacts";
|
|
if ($tn) $TableName = $tn;
|
|
|
|
|
|
|
|
// match email and record_num
|
|
$where_clause = "email = '$email' " .
|
|
"and record_num= '$record_num' " .
|
|
"and active = 'Y'";
|
|
|
|
$query = "select * from $TableName " .
|
|
"where $where_clause";
|
|
|
|
$results = db_query($query);
|
|
|
|
|
|
// if match
|
|
if (db_num_rows($results) > 0){
|
|
|
|
if ($confirmed) {
|
|
// set active to N
|
|
$query = "update $TableName set active = 'N'" .
|
|
"where email = '$email'" ;
|
|
$result = db_query($query);
|
|
|
|
// display thank you
|
|
echo("<p>You have been unsubscribed from this list.</p>\n");
|
|
echo ("$invite\n");
|
|
}
|
|
else {
|
|
echo("<p>Unsubscribe: <b>$email</b></p>\n");
|
|
echo("<form method=\"post\">\n");
|
|
echo("<input type=\"hidden\" name=\"email\" value=\"$email\">\n");
|
|
echo("<input type=\"hidden\" name=\"record_num\" value=\"$record_num\">");
|
|
echo("\n");
|
|
echo("<input type=\"hidden\" name=\"confirmed\" value=\"1\">\n");
|
|
echo("<input type=\"submit\" value=\" Confirm Unsubscribe \">\n");
|
|
echo("</form>\n");
|
|
}
|
|
}
|
|
else{
|
|
// if no match display error
|
|
// echo("<p>$query</p>\n");
|
|
echo("$error1\n");
|
|
echo("$invite\n");
|
|
echo($FOOTER);
|
|
return;
|
|
}
|
|
|
|
// end
|
|
echo($FOOTER);
|
|
?>
|