我的网站上有一个时事通讯订阅表格,我希望它转到一个页面
确认用户已注册。目前它只是刷新页面并给出
您在表单框所在的位置发送一条小消息。经过测试,它也不在乎是否
您将电子邮件地址输入错误等。我想要它,因此它会检查此信息并且仅
提交正确的电子邮件地址。目前那里的代码是
<?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;
?>