我在我的网站上订阅了一个通讯订阅表格,我希望它能进入一个页面,通讯确认/订阅确认
确认用户已注册。目前它只是刷新页面,并给出了一个小表达框的消息。已经测试了它,它也不会关心你是否
把电子邮件地址错误等,我想它,所以它会检查这些信息,只有
的提交正确的电子邮件地址。此刻的代码是
<?php
// get vars
$email_address = strtolower(trim($_REQUEST['email_address']));
if((strlen($email_address) > 0) && (strpos($email_address, "@")))
{
// add to db
$newsletterQry = db_query("SELECT * FROM newsletter_subscribers WHERE email='" . mysql_real_escape_string($email_address) . "'");
if(db_num_rows($newsletterQry) == 0)
{
// add
db_query("INSERT INTO newsletter_subscribers (email, created) VALUES ('" . mysql_real_escape_string($email_address) . "', NOW())");
}
}
// return back to the index page with confirmation
header("location: ".$_SERVER["HTTP_REFERER"]."?nlMsg=".urlencode("You've been added to the site newsletter."));
exit;
?>
*完全重复:* http://stackoverflow.com/q/5855811/1563422 – 2013-03-19 03:06:11