PHP登录不会立即更新网页
我有一个基于bootstrap3的网页。导航栏中有一个登录链接。当用户单击该链接时,会出现一个模式窗口,该模式窗口的内容来自login.php文件。提交用户名/密码后,模式窗口关闭 LOGIN.php:PHP登录不会立即更新网页,php,html,twitter-bootstrap,Php,Html,Twitter Bootstrap,我有一个基于bootstrap3的网页。导航栏中有一个登录链接。当用户单击该链接时,会出现一个模式窗口,该模式窗口的内容来自login.php文件。提交用户名/密码后,模式窗口关闭 LOGIN.php: <?php session_start(); if (isset($_POST['login_submit'])) { // I did not copy the processing to stop XSS/injection attacks if($usernam
<?php
session_start();
if (isset($_POST['login_submit'])) {
// I did not copy the processing to stop XSS/injection attacks
if($username != "" || $password != "") {
$found_user = attempt_login($username, $password);
if ($found_user) {
$_SESSION["user_name"] = $found_user["username"];
// should I have a http_redirect(?????????????) here?
}
else {
$_SESSION["message"] = "Username or password do not match our records. Please <a href='../inc/register.php'>register</a> or try again." ;
}
}
else {}
} ?>
<form name="login" class="form-horizontal" role="form" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<strong><center>Login </center></strong>
<div class="form-group">
<label for="input_username" class="col-sm-3 control-label">Username</label>
<div class="col-sm-9"><input name="username" type="text" id="user" class="form-control" placeholder="Username">
</div>
</div>
<div class="form-group">
<label for="input_username" class="col-sm-3 control-label">Password</label>
<div class="col-sm-9"><input name="password" type="password" id="pass" class="form-control" placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<input type="submit" name="login_submit" value="Login" class="btn btn-default" id="login_submit">
</div>
</div>
</form>
问题是:一旦用户单击submit后模式窗口关闭,用户就不会登录。它们只有在手动重新加载浏览器窗口后才能登录。如何使用户立即登录,并在单击“提交”后立即启动会话?不推荐使用HTML中心标记。只需提醒一下。您可以使用JS window.location.reload自动刷新页面,或者如果您的模式使用的是iframe,则可以使用parent.window.location.reload刷新页面。谢谢您的快速评论!不过,我还有一个更深层次的问题:我必须重新加载页面才能使登录会话生效,还是有其他方法?我不介意重新加载;我只想了解我自己教育的所有可能选项。@AndyGee我使用的是引导模式窗口,而不是iframe。我想我可以使用php来响应javascript窗口——这真的是确保重新加载会话数据的唯一解决方案吗?还是有一种更简洁的方法来实现这一点而不必重新加载整个页面?