Member Login

Member login

login.php

<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller
{
    public function index(){
        $admin=D('admin');
        if(IS_POST){
            if($admin->create($_POST,4)){
                if($admin->login()){
                    $this->success('登录成功,跳转中...',U('Index/index'));
                }else{
                    $this->error('用户名或者密码错误!');
                }
            }else{
                $this->error($admin->getError());
            }

            return;
        }

        $this->display();
    }
}

$_POST, 4 means that the fourth verification condition is used to judge the following model verification.

Verify data at the model layer

QQ截图20170621141910.png

Enter your account password and take a look

QQ截图20170621142531.png


Continuing Learning
||
<?php namespace Admin\Controller; use Think\Controller; class LoginController extends Controller { public function index(){ $admin=D('admin'); if(IS_POST){ if($admin->create($_POST,4)){ if($admin->login()){ $this->success('登录成功,跳转中...',U('Index/index')); }else{ $this->error('用户名或者密码错误!'); } }else{ $this->error($admin->getError()); } return; } $this->display(); } }
submitReset Code