<html>
<head>
<title>qrlogin</title>
<meta charset=
"UTF-8"
/>
</head>
<body>
<?php
require
'mysql_connect.php';
$randnumber
=
""
;
for
(
$i
=0;
$i
<8;
$i
++){
$randnumber
.=rand(0,9);
}
mysql_query(
"insert into login_data (randnumber) values ('$randnumber')"
)
?>
<img src=
"/static/imghw/default1.png"
data-src=
"http://qr.liantu.com/api.php?text=<?php echo $randnumber;? alt="
PHP网页生成二维码,Android客户端扫码登录
" >"
class
=
"lazy"
width=
"300px"
/>
<input hidden=
"hidden"
type=
"text"
name=
"randnumber"
id=
"randnumber"
value=
"<?php echo $randnumber;?>"
/>
</body>
<script>
xmlHttpRequest.onreadystatechange =
function
(){
if
(xmlHttpRequest.status == 200 && xmlHttpRequest.readyState ==4){
result = xmlHttp.responseText;
if
(result==true){
window.location.href='welcome.php';
}
}
}
}
function
polling(){
var
xmlHttpRequest;
if
(window.XMLHttpRequest){
xmlHttpRequest =
new
XMLHttpRequest();
}
else
{
xmlHttpRequest =
new
ActiveXObject(
"Microsoft.XMLHTTP"
);
}
randnumber = document.getElementById('randnumber').value;
xmlHttpRequest.open(
"GET"
,
"polling.php?randnumber="
+ randnumber,true);
xmlHttpRequest.send();
}
setInterval(
"polling()"
,1000);
</script>
</html>