21,886
社区成员
发帖
与我相关
我的任务
分享
$username = $_POST['username'];
$password = $_POST['password'];
$captcha = $_POST['captcha'];
$Captcha = new Captcha;
$Check = $Captcha->CheckCap($captcha);
if($Check) {
$Adminusers = model('Adminuser');
$result['check'] = $Adminusers->CheckLogin($username,$password);
<?php
namespace app\Admin\Controller;
use think\Controller;
use app\Admin\Model;
use think\Session;
//后台登录类
class Login extends Controller {
public function index() { //登录页展示
return $this->fetch();
}
public function Ajaxlogin() { //验证登录
$username = $_POST['username'];
$password = $_POST['password'];
$captcha = $_POST['captcha'];
$Captcha = new Captcha;
$Check = $Captcha->CheckCap($captcha);
if($Check) {
$Adminusers = model('Adminuser');
$result['check'] = $Adminusers->CheckLogin($username,$password);
if($result['check']) {
Session::set('Adminer',$username); //登录成功
}
else {
$result['content'] = '账号信息有误!';
}
}
else {
$result['content'] = '验证码错误!';
}
return $result;
}
}
这是我的验证文件<?php
namespace app\Admin\Controller;
use think\Controller;
class Captcha extends Controller {
public function CheckCap($captcha = '') {
if(!captcha_check($captcha)) {
return false;
}
else {
return true;
}
}
}
这是我的Captcha文件,我在windows上就是正常的
这里是这个文件的上面部分
namespace app\Admin\Controller;
use think\Controller;
use app\Admin\Model;
use think\Session;
//后台登录类
class Login extends Controller {