注册后,验证邮件和电子邮件尚未经过验证

时间:2015-10-03 14:10:09

标签: php codeigniter frameworks

我创建一个菜单登录并注册电子邮件验证。但是,如果电子邮件尚未经过验证,我会想要显示消息“您的电子邮件尚未经过验证”我应该添加到我的脚本中...

前:

有效= 1(已经过验证)

有效= 0(未经验证)

控制器:

  <div data-role="main" class="ui-content">
<div data-role="collapsible">
  <h1>Click me - I'm collapsible!</h1>
  <p>I'm the expanded content.</p>
</div>

2 个答案:

答案 0 :(得分:1)

您必须首先检查用户凭据是否正确,然后检查电子邮件是否已经过验证。

所以,你可以试试这个:

public function do_login() {

    $data = $this->input->post(null, true);

    $user = $this->db->get_where('user', array(
        'email'=>$data['email'],
        'password'=>$data['password']
         ))->row();

    if ($user) {    //User exists
        if ($user->active == 1) {   //User exists and his email is verified
            $session_set = array(
                'is_login'  => true,
                'firstname' => $user->firstname,
                'lastname'  => $user->lastname,
                'jkl'       => $user->jkl,  
                'id'        => $user->id,               
                'lastlogin' => $user->lastlogin
            );

            $this->db->update('user', array('lastlogin'=>date('Y-m-d H:i:s')), array('id'=>$user->id));
            $this->session->set_userdata($session_set);
            redirect('homepage/homepage/menu');   

        } else {    //User exists BUT his email is NOT verified

            $this->session->set_flashdata('message', 'Your email is not verified yet');
            //You have to capture and show the flash message in view

            redirect('login/login/index/error');
        }
    } else {    //User does NOT exist at all

        $this->session->set_flashdata('message', 'The combination of username and/or password was incorrect. Please, try again.');
        //You have to capture and show the flash message in view

        redirect('login/login/index/error');
    }
}

在你看来,有点像:

<?php if ($this->session->flashdata('message')) : ?>
<p class="someErrorClass"><?php echo $this->session->flashdata('message'); ?></p>
<?php endif; ?>

答案 1 :(得分:0)

我认为您希望每当您向其发送验证电子邮件的特定用户再次访问您的网站时,都会显示此信息。 据我所知,你必须考虑在他/她的机器上放置一个cookie,并在任何用户访问你的网站时检查它是否存在。希望能帮助您一路走来。