0
索引頁的設計是這樣tat它通過jquery請求登錄後檢索數據...我的懷疑是tat如何維護頁面,如果手動刷新被執行或可以我執行任何功能,如果手動刷新執行?下面是我的一些代碼..如何執行一個功能,如果手動刷新
Checklogin.php
<?php
session_start();
include('dbconnect.php');
$email=mysql_real_escape_string($_REQUEST['email']);
$pass=mysql_real_escape_string($_REQUEST['pass']);
$pass=filter_var($pass, FILTER_SANITIZE_STRING);
$email=filter_var($email, FILTER_SANITIZE_EMAIL);
$query="SELECT * from `users` WHERE `email`='$email' and `pass`='$pass'";
$res=mysql_query($query) or die("Error in query");
$res1=mysql_num_rows($res);
$name="guest";
if($res1 == 0)
{
$query="SELECT * from `users` WHERE `email`='$email'";
$res=mysql_query($query) or die("Error in query");
$res2=mysql_num_rows($res);
if($res2>0){
$code=3;
echo json_encode(array('name'=>$name,'code'=>$code));
}
else{
$code=2;
echo json_encode(array('name'=>$name,'code'=>$code));
}
}
else
{
$code=1;
$row = mysql_fetch_assoc($res);
$name=$row['name'];
$_SESSION['email']=$email;
$_SESSION['name']=$name;
$query="select * from crown1 where email='".$_SESSION['email']."';";
$res=mysqli_query($con,$query);
$row=mysqli_fetch_array($res);
$level=$row['level'];
$points=$row['points'];
$rank=$row['rank'];
$times="time".$level;
$timest=$row[$times];
$query="select * from qna where level=".$level.";";
$res9=mysqli_query($con,$query);
$row9=mysqli_fetch_array($res9);
$title=$row9['title'];
$qn=$row9['qnlink'];
$_SESSION['title']=$title;
$_SESSION['qnlink']=$qn;
$_SESSION['level']=$level;
$_SESSION['points']=$points;
$_SESSION['timest']=$timest;
$_SESSION['rank']=$rank;
//echo $_SESSION['email'];
echo json_encode(array('name'=>$_SESSION['name'],'code'=>$code));
}
?>
leader.js
var loadData = function(){
var url = 'Leaders.php';
$.getJSON(url, function(data) {
$('#Leaders').empty().append('<ul style="position: absolute; margin: 0px; padding: 0px; top: 0px; list-style-type:none; width:100%">');
$.each(data, function(index, data) {
$('#Leaders>ul').append("<li style='margin: 0px; padding: 0px; height: 30px; width:100%'> #"+data.rank+" "+data.name+"<span class='myNumber' name='n1' style='float:right;'> "+data.points+" </span></li>");
});
$('#Leaders').append('</ul>');
});
var url = 'Game.php';
$.getJSON(url, function(data) {
$('#points').empty().append(data.points);
$('#level').empty().append(data.level);
$('#ranking').empty().append(data.rank);
$('#levelUsers').empty().append(data.users);
$('#totalPlayers').empty().append(data.nousers);
$('#titlediv>div>h3>center').empty().append(data.title);
$('#game3').empty().append("<img src='"+data.qnlink+"' style='width:700px;height:250px;'/>");
//setIntervalOnce(loadData, 5000);
});
}
我打電話LoadData()Checklogin被稱爲後...
_manual refresh_?你的意思是通過瀏覽器刷新按鈕? – putvande
這看起來像是你只是想在運行一個函數,如果頁面加載和用戶登錄。爲什麼特別是如果瀏覽器手動重新加載? –
是的...因爲所有我通過此LoadData()加載的內容丟失,頁面變爲空白...即在刷新 –