-2
我試圖讓網站有我有登錄系統管理員管理時成功登錄比分配會議,但這次會議到期時頁面refresh.Check下面我顯示你我有什麼完成。我每次當頁面刷新時間未設置會話
的Html
<form action="../../system/access/checking.php" class="form-signin">
<h2 class="form-signin-heading">Please sign in</h2>
<input type="text" id="user" class="form-control" placeholder="Email address" required autofocus>
<input type="password" id="pass" class="form-control" placeholder="Password" required>
<a class="btn btn-lg btn-primary btn-block" onclick="submitfom();" >Sign in</a>
</form>
阿賈克斯
function submitfom() {
$.ajax({
type: "POST",
url: "../../system/access/checking.php",
data: {user: $("#user").val(),pass: $("#pass").val()},
success: function(data){
if(data == true){
window.location.href = '../../index.php';
} else {
$('#show-error').slideDown("slow",function(){$('#show- error').html(data);$('#show-error').css("display","inline");});
};
}
});
}
PHP
include('../../../config.php');
if((isset($_POST['user'])) && (isset($_POST['pass']))){
$user = $_POST['user'];
$pass = $_POST['pass'];
$query = mysql_query("SELECT user FROM admin_user WHERE user ='".$user."' ");
$query2 = mysql_query("SELECT pass FROM admin_user WHERE pass ='".$pass."' ");
$result= mysql_num_rows($query);
$result2= mysql_num_rows($query2);
if((!empty($result)) && (!empty($result2))){
session_set_cookie_params('3600');
session_start();
$_SESSION['admin']=$user ;
session_write_close();
echo true;
}
else {
echo "Please Write correct <strong>username and password</strong>";
}
}
else {
echo "Some thing miss";
}
'在session_start()'需要去你希望在使用會話的每個頁面的頂部* *。 –
請詳細說明您所做的調試進度。另外還不清楚在這裏要問什麼。 – 19greg96
你需要'在session_start();'在每一頁上,還需要更新您的MySQL來的mysqli或PDO或者你會得到砍死。 – cmorrissey