var storage = window.localStorage; var key = null; $('#login').click(function(){ var uname = $("#name").val(); var upwd = $("#pwd").val(); var md5=hex_md5(upwd); $.post("PHP/dengluphp/guanliyuandenglu.php",{uname:uname,upwd:md5},function(data){ if(data.msg=='exit') { if(data[0].ustate=="正常"){ console.log(data); // location.href="guanliyuan.html"; key = 'username'; var value = uname; storage.setItem(key,value); key = null;//释放资源 // console.log(data[0].ujob); var level=data[0].ujob; if(level=="管理员"){ // location.href="guanliyuan.html?level="+level; }else if(level=="一级代理"){ location.href="yijidaili.html?level="+level; }else if(level=="二级代理"){ location.href="erjidaili.html?level="+level; }else if(level=="三级代理"){ location.href="sanjidaili.html?level="+level; } }else{ alert('您的账号已被停封,请联系管理员'); } }else{ alert('您输入的账号或密码错误'); } }) })
<?php header("Content-Type:appliction/json;charset=UTF-8"); $uname = $_REQUEST['uname']; $upwd = $_REQUEST['upwd']; if(empty($uname)){ echo '[]'; return; }; $conn = mysqli_connect("服务器的ip",'root','mysql的密码',"group666",3306); $sql = "SET NAMES UTF8"; mysqli_query($conn,$sql); $sql = "SELECT * FROM firdaili WHERE uname='$uname' AND upwd='$upwd'"; $result = mysqli_query($conn,$sql); $output = []; while(($row=mysqli_fetch_assoc($result))!==NULL){ $output[] = $row; $output['msg'] = 'exit'; }; echo json_encode($output); ?>在linux上装了phpstudy,把文件都放到www文件中
然后浏览器输入ip能访问到页面,进行异步请求时就出现错误
jquery-3.1.1.min.js:4 POST http://139.224.70.248/mysqlhoutai/PHP/dengluphp/guanliyuandenglu.php 500 (Internal Server Error)
-
Request URL:http://139.224.70.248/mysqlhoutai/PHP/dengluphp/guanliyuandenglu.php
-
Request Method:POST
-
Status Code:500 Internal Server Error
-
Remote Address:139.224.70.248:80
- Response Headersview source
-
Connection:close
-
Content-Length:0
-
Content-Type:text/html
-
Date:Tue, 06 Dec 2016 04:28:19 GMT
-
Server:Apache/2.4.7 (Unix) PHP/5.3.27
-
X-Powered-By:PHP/5.3.27
- Request Headersview source
-
Accept:*/*
-
Accept-Encoding:gzip, deflate
-
Accept-Language:zh-CN,zh;q=0.8
-
Connection:keep-alive
-
Content-Length:47
-
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
-
Host:139.224.70.248
-
Origin:http://139.224.70.248
-
Referer:http://139.224.70.248/mysqlhoutai/
-
User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36
-
X-Requested-With:XMLHttpRequest
- Form Dataview sourceview URL encoded
PHP/5.3.27
这个版本的php支持$output = []这样声明数组?5.4以上才行吧