Rumah > Soal Jawab > teks badan
//登录(html) function dologin(){ var username = $.trim($('#username').val()); var password = $.trim($('#password').val()); var verifycode = $.trim($('#verifycode').val()); if(username == ''){ layer.alert('请输入用户名',{icon:2}); return; } if(password == ''){ layer.alert('请输入密码',{icon:2}); return; } if(verifycode==''){ layer.alert('请输入验证码',{icon:2}); return; } $.post('/admins.php/admins/Account/dologin',{'username':username,'password':password,'verifycode':verifycode},function(res){ if(res.code>0){ reloadImg(); layer.alert(res.msg,{icon:2}); }else{ layer.msg(res.msg); setTimeout(function(){window.location.href = '/admins.php/admins/Home/index'},1000); } },'json') //控制器(controller) public function dologin(){ $username = trim(input('post.username')); $pwd = trim(input('post.password')); $verifycode = trim(input('post.verifycode')); if($username == ''){ exit($res = json_encode(array('code'=>1,'msg'=>'用户名不能为空'))); } if($pwd == ''){ exit($res = json_encode(array('code'=>1,'msg'=>'密码不能为空'))); } if($verifycode == ''){ exit($res = json_encode(array('code'=>1,'msg'=>'请输入验证码'))); } // 验证验证码 if(!captcha_check($verifycode)){ exit($res = json_encode(array('code'=>1,'msg'=>'验证码错误'))); } // 验证用户 $this->db = new Sysdb; $admin = $this->db->table('admins')->where(array('username'=>$username))->item(); if(!$admin){ exit($res = json_encode(array('code'=>1,'msg'=>'用户不存在'))); } if(md5($admin['username'].$pwd) != $admin['password']){ exit($res = json_encode(array('code'=>1,'msg'=>'密码错误'))); } if($admin['status'] == 1){ exit($res = json_encode(array('code'=>1,'msg'=>'用户已被禁用'))); } // 设置用户session session('admin',$admin); exit($res = json_encode(array('code'=>0,'msg'=>'登录成功'))); }
驱魔鮔2019-01-02 20:36:57
Salam, ingin bertanya, adakah masalah anda telah selesai? Saya juga menghadapi masalah. Tiada jawapan apabila saya klik OK Konsol memaparkan 404 tidak dijumpai