我有php脚本负责退订时事通讯用户。
<?php
session_start();
$without_login = 1;
include("includes/config.inc.php");
if(!(isset($_REQUEST['email']) && $_REQUEST['email'] != ''))
{
header("location:".$basehref);
exit(0);
}
$meta_title = 'Unsubscribe - '.store_company_name;
$meta_desc = '';
$meta_keyword = '';
include("header.php");
?>
<div class="content" itemscope itemtype="http://schema.org/WebPage">
<div class="pnav" itemprop="breadcrumb"><a href="<?php echo $basehref;?>" title="Home">Home</a> » <span id="on1">Unsubscribe From Mailing List</span></div>
<section>
<div class="about">
<h1 itemprop="about">Unsubscribe From Mailing List</h1>
<hr>
<div itemprop="description" id="static_desc">
<form action="" method="post" name="form">
<input type="hidden" name="unsubscribe_email" id="unsubscribe_email" value="<?php echo mysql_real_escape_string($_REQUEST['email']);?>" />
<div class="story_left" style="min-height:200px;"><br />
<?php
$error = 0;
$to = $_REQUEST['email'];
$encrypt_email = decode5t($to);
if($encrypt_email != '')
{
$check_url = mysql_query("select * from tb_member where `email` = '".$encrypt_email."' and newsletter = 1");
if(mysql_num_rows($check_url) > 0)
{
$error = 1;
}
if($error == 0)
{
$check_url = mysql_query("select * from news_letters where `email` = '".$encrypt_email."'");
if(mysql_num_rows($check_url) > 0)
{
$error = 1;
}
}
}
if($error == 0)
{
echo 'The unsubscribe link you have clicked is invalid. <br> <br /> <input type="button" onclick="window.location='''.$basehref.''';" value="Continue" title="Continue" style="float:left; margin-left:250px;" class="choose-btn1" name="submit" />';
}
else
{
?>
Please confirm your unsubscribe request from <?php echo store_company_name;?> newsletters by clicking on the "Unsubscribe" button below to remove your email address.<br /><br />
<input type="button" class="ungo-btn choose-btn1" title="Unsubscribe" value="Unsubscribe" name="submit" style="float:left; margin-right:20px;" />
<input type="button" onclick="window.location='<?php echo $basehref;?>';" value="Cancel" title="Cancel" style="float:left;" class="choose-btn1" name="cancel" />
<?php
}
?>
</div>
</form>
</div>
</div>
</section>
<div class="clear"></div>
</div>
<?php
include("footer.php");
?>
有人能告诉我如何把命令放入链接中开始取消订阅用户吗?我正在使用下面的一个,但没有成功。
<a href='http://www.xyz.co.uk/unsubscribe.php?email=$_REQUEST['email']'>UNSUBSCRIBE HERE</a>
我认为你的脚本没有取消订阅用户,因为没有mysql查询来更新数据库。
下面的代码表明用户需要单击提交按钮来处理数据,在您的示例中是取消订阅用户。
<input type="button" class="ungo-btn choose-btn1" title="Unsubscribe"
value="Unsubscribe" name="submit" style="float:left; margin-right:20px;" />
但是,即使在用户单击提交按钮之后,我也不确定数据发送到哪里,因为表单操作是",参见以下内容:
<form action="" method="post" name="form">
假设newsletter=1表示用户订阅了时事通讯,下面是一个简单的示例,脚本将更新数据库并设置newsletter=0(不明嫌犯newsletter)
$to = $_REQUEST['email'];
$encrypt_email = decode5t($to);
if($encrypt_email != '')
{
$check_url = mysql_query("select * from tb_member where `email` = '$encrypt_email' and newsletter = 1");
if(mysql_num_rows($check_url) > 0)
{
mysql_query("UPDATE tb_member set newsletter = '0' where `email` = '$encrypt_email' and newsletter = 1");
$error = 1;
}
if($error == 0)
{
$check_url = mysql_query("select * from news_letters where `email` = '$encrypt_email'");
if(mysql_num_rows($check_url) > 0)
{
mysql_query("UPDATE tb_member set newsletter = '0' where `email` = '$encrypt_email'");
$error = 1;
}
}
}
if($error == 0)
{
echo "The unsubscribe link you have clicked is invalid";
}