0

ログインに成功した後、ユーザーを index.php にリダイレクトしようとしています。リダイレクト以外はすべて機能しています。約1時間見回しましたが、運がありません..ページを所有している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"

4

1 に答える 1

0

こんにちは、完全なドメインをそこに入れたいと思うかもしれません。私もこの問題を抱えていました

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

私はそれがトリックを行うべきだと信じています

于 2013-04-10T19:11:06.687 に答える