You need two files... one to subscribe another to unsubscribe
Code:
<?
#
# $Id: whp_subscribe.php,v 1.19 2002/11/18 10:59:49 acidleak Exp $
# allows u to subscribe to the newsletter from another site
#
require "../smarty.php";
require "../config.php";
require "../mail/func.php";
include "../include/get_language.php";
$email = trim(($email));
echo("Subscribing...");
if (!is_correct_efunc_send_mail($email)) {
//header("Location: ../$redirect/error_message.php?subscribe_bad_email");
echo("<html><body><center>You have to enter your email
<a href=\"javascript:this.close()\">Close this WIndow</a></body></html>");
} else {
$result = db_query("select count(*) from $sql_tbl[maillist] where email='$email'");
list($c) = db_fetch_row($result);
db_free_result($result);
if ($c > 0) {
//header("Location: ../$redirect/error_message.php?subscribe_exist_email");
echo("<html><body><center>Email already Exists
<a href=\"javascript:this.close()\">Close this WIndow</a></body></html>");
} else {
db_query("insert into $sql_tbl[maillist] values('$email', '".time()."')");
echo("<html><body><center>Thank You
<a href=\"javascript:this.close()\">Close this WIndow</a></body></html>");
#
# Send mail notification to customer
#
$mail_smarty->assign("email",$email);
func_send_mail($email, "mail/newsletter_subscribe_subj.tpl", "mail/newsletter_subscribe.tpl", $config["Company"]["newsletter_email"], false);
#
# Send mail notification to admin
#
func_send_mail($config["Company"]["newsletter_email"], "mail/newsletter_admin_subj.tpl", "mail/newsletter_admin.tpl", $email, true);
// header("Location: ../home.php?mode=subscribed&email=".urlencode($email));
}
}
?>
unsubscribe...
Code:
#
# $Id: whp_unsubscribe.php,v 1.19 2002/11/14 07:58:19 acidleak Exp $
# unsubscribe from newsletter
#
echo("Unsubscribing...");
require "../smarty.php";
require "../config.php";
require "../mail/func.php";
include "../include/get_language.php";
$email = trim($email);
if (!is_correct_efunc_send_mail($email)) {
echo("<html><body><center>You have to enter your email
<a href=\"javascript:this.close()\">Close this WIndow</a></body></html>");
exit;
} else {
$result = db_query("select count(*) from $sql_tbl[maillist] where email='$email'");
list($c) = db_fetch_row($result);
db_free_result($result);
if ($c < 1) {
echo("<html><body><center>Email doesnt Exists
<a href=\"javascript:this.close()\">Close this WIndow</a></body></html>");
exit;
} else {
db_query("delete from $sql_tbl[maillist] where email='$email'");
echo("<html><body><center>Thank You
<a href=\"javascript:this.close()\">Close this WIndow</a></body></html>");
#
# Send mail notification to customer
#
$mail_smarty->assign("email",$email);
func_send_mail($email, "mail/newsletter_unsubscribe_subj.tpl", "mail/newsletter_unsubscribe.tpl", $config["Company"]["newsletter_email"], false);
#
# Send mail notification to admin
#
func_send_mail($config["Company"]["newsletter_email"], "mail/newsltr_unsubscr_admin_subj.tpl", "mail/newsltr_unsubscr_admin.tpl", $email, true);
// header("Location: ../customer/home.php?mode=unsubscribed&email=".urlencode($email));
}
}
?>
... and the subscription form...you can place it on any other site. I used popup window and a form, but any other way to pass the email variable to the link can be used
Code:
<head>
....
<SCRIPT>
<!--
function openPopup(email) {
var unsubscribe_checked = window.document.emailform.unsubscribe.checked;
if(!email){
alert("Please enter your email...");
}
else if(email == "your email..."){
document.emailform.email.focus();
document.emailform.email.style.backgroundColor="#f2f2f2";
return;
}
else {
var x=-30;
var y=-60;
if (document.layers) {
x=x+(window.outerWidth-200)/2;
y=y+(window.outerHeight-50)/2;
}
else {
x=x+(screen.Width-200)/2;
y=y+(screen.Height-50)/2;
}
if (x<0) x=0;
if (y<0) y=0;
if(!unsubscribe_checked){
var w=window.open("http://www.worldhealthproducts.com/custmods/whp_subscribe.php?email="+email+"","whpnewsletter","top="+y+",left="+x+",width=200,height=50,location=0,menubar=0,toolbar=0,status=0,resizable=0,scrollbars=0");
}
else
{
var w=window.open("http://www.worldhealthproducts.com/custmods/whp_unsubscribe.php?email="+email+"","whpnewsletter","top="+y+",left="+x+",width=200,height=50,location=0,menubar=0,toolbar=0,status=0,resizable=0,scrollbars=0");
}
w.focus();
}
return;
}
//-->
</SCRIPT>
</head>
.....
<form name="emailform" style="border: 0; padding: 0; margin: 0">
<input type="text" name="email" value="your email..." size="20" onClick="this.value=''">
<input type="button" name="ok" value="Ok" onClick="openPopup(document.emailform.email.value)">
</form>