【发布时间】:2014-09-16 16:13:42
【问题描述】:
在视图中我有两个文件夹页面,模板。内页我有两个文件夹非会员和会员。 在模板里面我有 header.php 和 footer.php。 在非成员文件夹中,我有一个通知文件 email_notification.php 以及其他文件,例如 home.php、about.php 等
页面正在使用以下函数动态生成
public function index(){
$this->nonmember();
}
public function nonmember($page = 'home'){
if (! file_exists(APPPATH.'views/pages/nonmember/'.$page.'.php')) {
show_404();
}
$data['title'] = ucfirst($page);
$this->load->view('templates/header', $data);
$this->load->view('pages/nonmember/'.$page, $data);
$this->load->view('templates/footer', $data);
}
并调用它以显示登录页面或注册页面
public function registration(){
//validation rules
if($this->form_validation->run()){
//add user to a temporary table
//send an email with an activation code
$this->nonmember('email_notification');
//that view says click the link in email for activating account
}else{
$this->nonmember('registration');
}
}
问题是 email_notification 视图也可以通过 url 访问,这是不可取的。 如何防止 email_notification 直接访问?就像用户尝试使用 url 访问它一样 我想将它们重定向回主页,或者 show_error() ?
【问题讨论】:
-
我建议你设置一个会话变量,如果视图不存在就不要加载它。
-
显示
email_notification。 -
@DwayneTowell email_notification 只是一个正文部分,表示已发送一封带有激活链接的电子邮件,单击该链接激活您的帐户。但请参阅我自己的答案,我按照 James Lator 的建议使用。
标签: php codeigniter