2013-04-10 168 views
0

嘗試在成功登錄後將用戶重定向到index.php。除了重定向之外,我有一切工作。現在已經看遍了大約一個小時,沒有luck..I'm確保它被拴jQueryMobile擁有的頁面JQueryMobile登錄頁面成功登錄時重定向

試過

header('Location: index.php'); 

沒有任何反應。

也試過

echo '<script type="text/javascript">$.mobile.changePage($(\'index.php\'), {transition : "slide"});</script>'; 

兩個做了重新直接,如果我讓他們我的PHP代碼的第一部分,但放置時,我需要它,他們什麼都不做。

這裏是我的代碼:

<?php include "layouts/header.php"; 
if (isset($_POST['submit'])) { // Form has been submitted. 

    $username = trim($_POST['username']); 
    $password = trim($_POST['password']); 

    // Check database to see if username/password exist. 
    $hashpass = sha1($password); 
    $found_user = User::authenticate($username, $hashpass); 

    if ($found_user) { 
    $session->login($found_user); 
    $message = "Logged in"; 
    // Redirect to index.php ******** 

    } else { 
    // username/password combo not found 
    $message = "Username/password combination incorrect."; 
    $forgotdisplay = "visible"; 
    } 

} else { // Form was not been submitted. 
    $username = ""; 
    $password = ""; 
} 
?> 
</head> 
<body> 
<div data-role="page" id="loginForm"> 
    <div data-role="header"> 
     <h1>Assessment</h1> 
    </div> 
    <div data-role="content" class="centerContent"> 
     <h2>Login</h2> 
     <p><?php echo output_message($message); ?></p> 
     <form action="login.php" method="post" data-ajax="false"> 
      <table> 
      <input type="text" id="username" name="username" maxlength="50" placeholder="username" value="<?php echo htmlentities($username); ?>" /> 
      <input type="password" id="password" name="password" maxlength="30" placeholder="password" value="<?php echo htmlentities($password); ?>" />    
      <input type="submit" name="submit" value="Login" />  
     </form> 
     <a href="register.php" data-role="button" data-transition="slide">Sign Up</a> 
     <a href="forgot.php" data-role="button">Forgot Your Password?</a> 
     <p id="validate-status"></p> 
    </div> 
</div> 
</body> 
</html> 

當有效憑據提交的$message不正確地更改爲「登錄」,所以我知道我得到的腳本爲止。也試過用data-ajax="false""true"

回答

0

你好,你可能想把完整的域放在那裏。我有這個問題太

header('location: www.yourdomain.com/index.php'); 

我認爲應該做的伎倆

+0

要是我的手指上那一個,沒有運氣.. – user2267461 2013-04-10 19:16:36

+0

對不起交叉,你有沒有試圖把'HTTP://www.yourdomain。 com/index.php' – user1819037 2013-04-10 19:23:09

+0

是的,試過了。什麼都沒發生。我在重定向行之後添加了$ message =「沒有重定向」,並且顯示了該消息。這就像任何嘗試重定向頁面被忽略。 – user2267461 2013-04-10 19:27:35