Extended CodeIgniter User Login Verification _php Tutorial

Source: Internet
Author: User
You need to modify the login verification module of my_controller.php and controller user.php as follows:

my_controller.php

Class My_controller extends ci_controller{public    function __construct ()    {        parent::__construct ();        /* Determine if you are logged in and determine if the current URL is auth/login*/        if (! $this->tank_auth->is_logged_in ()                && ($this Router->fetch_class ()! = ' Auth ' && $this->router->fetch_method ()! = ' login ')        } {            $redirect = $ This->uri->uri_string ();                    if ($_server[' query_string ')            {                $redirect. = '? '. $_server[' query_string '];            }            /* Jump to the user login page, specify login to jump to url*/            redirect (' auth/login?redirect= '. $redirect);}}        

user.php

Class User extends My_controller {function login () {if ($this->tank_auth->is_logged_in ()) {        Logged in redirect ('/'); } else {//other codes .../* Determine if there is redirect information */$data [' redirect '] = Isset ($_get[' re Direct '])?            $_get[' redirect ': '/'; if ($this->form_validation->run ()) {//validation ok if ($this->ta Nk_auth->login ($this->form_validation->set_value (' login '), $this-&                        Gt;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: In Login_form, you need to be aware that the form address is submitted:

 
  

In Login_form, you need to note that the form address of the submission forms:

 
  

http://www.bkjia.com/PHPjc/752347.html www.bkjia.com true http://www.bkjia.com/PHPjc/752347.html techarticle need to modify my_controller.php and Controller login Verification module user.php, code as follows: my_controller.php class My_controller extends ci_controller{ Public Function __construct ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.