tp3.2 Login Exit

Source: Internet
Author: User
Public Function Index () {
      if (is_post) {
          $admin =d (' admin ');
          if ($admin->create ($_post,4)) {
            //   Dump ($admin->create ($_post,4));   die;
              if ($admin->login ()) {
                  $this->success (' login succeeded ', U (' Index/index '));
              } else{
                  $this->error (' username or password is wrong. ');
              }
          } else{
              $this->error ($admin->geterror ());
          }
          return;
        }
        $this->display ();
    }

This is the login controller inside the method, used to receive the login interface from the account and password, $admin->create ($_post,4) Why use 4 it, because in the administrator of the controller inside, there are model models, have to add data, edit data, There are all the conditions attached, and the login This is the fourth kind of gas mine to prevent automatic verification, the focus is login () This method of writing, go to admin this module inside

Public Function Login () {
        $password = $this->password;
        Dump ($this->username);
        Die;
        $data [' username ']= $this->username;
        $info = $this->where ($data)->find ();
        Dump ($info);
        Die;
        if ($info) {
            if ($info [' Password ']==md5 ($password)) {session
                (' ID ', $info [' id ']);
                Session (' username ', $info [' username ']);
                return true;
            } else{return
                false;
            }
        else{return
            false;
        }

$this->password on behalf of the reception received the password, $this->username representative to accept the front desk account, and then recorded in the data array and then query ¥admin username= $this-> Username this line of data,

If the ¥info this data is not NULL to indicate that there is this account, otherwise there is no return false, if Moma is equal to the password after encryption, name the account exists in the session array

It's a pretty cheap egg. Clear the value on the session.

Public Function Layout () {session
        (NULL);
        $this->redirect (' Login/index ');
    }


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.