Php 试图让我的新闻稿订阅确认页面仅在用户通过确认电子邮件访问时才可访问
我在做一个通讯系统 我有一个输入类型的文本,用户写他的电子邮件,然后点击提交订阅新闻稿 之后,用户将收到一封电子邮件,说要确认他的订阅,他需要单击我在收到的确认电子邮件中提供的确认链接 这个链接将重定向到我的新闻稿确认页面,在那里我进行更新,在我的数据库表中订阅这个用户 这是重定向链接:Php 试图让我的新闻稿订阅确认页面仅在用户通过确认电子邮件访问时才可访问,php,.htaccess,Php,.htaccess,我在做一个通讯系统 我有一个输入类型的文本,用户写他的电子邮件,然后点击提交订阅新闻稿 之后,用户将收到一封电子邮件,说要确认他的订阅,他需要单击我在收到的确认电子邮件中提供的确认链接 这个链接将重定向到我的新闻稿确认页面,在那里我进行更新,在我的数据库表中订阅这个用户 这是重定向链接: http://localhost/website/newsletter/confirm/useremail@email.com/b443e5a143bb54b4313dfferef3 一切正常,但我希望我的时
http://localhost/website/newsletter/confirm/useremail@email.com/b443e5a143bb54b4313dfferef3
一切正常,但我希望我的时事通讯订阅确认页面只有在用户从收到的确认电子邮件访问链接时才可用
我不认为用户可以访问此页面“http://localhost/website/newsletter/confirm/
”,因为此页面没有任何内容可显示,只有在用户
从确认链接访问此页面,因为此页面将获取url变量(电子邮件和代码),并在我的表中执行更新,并显示消息“Subscription with Success”
你知道我怎么做吗
在我的查询字符串中我尝试这样做:
$url = $_GET['url'];
$url = explode('/', $url);
$url[0] = ($url[0] == NULL ? 'index' : $url[0]);
$newsletter = 'newsletter';
$confirm = 'confirm';
if(file_exists('template/'.$url[0].'.php')){
require_once('template/'.$url[0].'.php');
}
//here its what Im trying for this purpose
elseif(file_exists('template/'.$newsletter.'/'.$confirm.'.php')){
require_once('template/404.php');
}
elseif(file_exists('template/'.$url[0].'/'.$url[1].'/'.$url[2].'.php')){
require_once('template/'.$url[0].'/'.$url[1].'/'.$url[2].'.php');
}
elseif(file_exists('template/'.$url[0].'/'.$url[1].'.php')){
require_once('template/'.$url[0].'/'.$url[1].'.php');
}
else{
require_once('template/404.php');
}
}
但就像这样,我总是输入我的404.php文件,即使我通过确认电子邮件链接“http://localhost/website/newsletter/confirm/useremail@email.com/b443e5a143bb54b4313dfferf3
”
我想在一些用户试图访问时包含404.php文件“http://localhost/website/newsletter/confirm/
“,
当访问未通过电子邮件中的确认链接完成时
你知道我该怎么做吗?如果confirm.php检测到变量缺失/值错误,你就不能在confirm.php中重定向/包含你的主要时事通讯页面(例如你的主页)吗?或者在检查变量后包括/要求404页面?谢谢ccKep。我用你的小费解决问题!