I followed the teacher's code but kept reporting this error: 500 (Internal Server Error)
帅气的勇士
帅气的勇士 2018-12-11 18:01:19
0
2
1613
//登录(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'=>'登录成功')));
	}			
			
			
			
			
			
			
			
			
			
			


帅气的勇士
帅气的勇士

reply all(1)
驱魔鮔

Hello, would you like to ask, has your problem been solved? I also have a problem. There is no response when I click OK. The console displays 404 not found


  • reply Solved. I kept reporting 500 errors. I always thought there was a problem with the server. Later, I carefully checked the code and found that the code was written incorrectly. I suggest you check your own code carefully and don’t miss a letter. Be patient.
    帅气的勇士 author 2019-01-02 20:56:43
  • reply I did write the code in the background wrong, thank you.
    驱魔鮔 author 2019-01-20 14:56:29
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!