Home >Backend Development >PHP Tutorial >Codeigniter implements URL jump after processing user login verification_PHP tutorial

Codeigniter implements URL jump after processing user login verification_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:28:311091browse

Codeigniter handles URL jump after user login verification, which mainly involves the My_Controller.php page and the login verification module User.php page. The specific code is as follows:

My_Controller.php page:

Copy code The code is as follows:
class MY_Controller extends CI_Controller
{
public function __construct()
{
parent::__construct();
/* Determine whether to log in and determine whether the current URL is auth/login*/
if ( ! $this->tank_auth->is_logged_in()
&& ( $this->router->fetch_class() != 'auth' && $this->router->fetch_method() != 'login'))
                                                                      ->uri->uri_string();

                                                                                                                                                                                 ;
                                                                                                                                                                           }
}



User.php page:


Copy code The code is as follows:

class User extends MY_Controller
{
    function login()
    {

        if ($this->tank_auth->is_logged_in()) {                                    // logged in
            redirect('/');

        } else {
            //other codes here......
            /*判断是否有redirect信息*/
            $data['redirect'] = isset($_GET['redirect']) ? $_GET['redirect'] : '/';

            if ($this->form_validation->run()) {                                // validation ok
                if ($this->tank_auth->login(
                        $this->form_validation->set_value('login'),
                        $this->form_validation->set_value('password'),
                        $this->form_validation->set_value('remember'),
                        $data['login_by_username'],
                        $data['login_by_email'])) {                                // success
                    redirect($data['redirect']);

                } else {
                    //error handling
                }
            }
            $this->load->view("login_form")
        }
    }
/*
Note: 在login_form中需要注意,提交表单的form地址:

*/
}

在login_form中需要注意,提交表单的form地址为:

复制代码 代码如下:

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/788609.htmlTechArticleCodeigniter处理用户登录验证后URL跳转,主要涉及到了My_Controller.php页面以及登录验证模块User.php页面,具体代码如下: My_Controller.php页面:...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn