[英]another javascript redirecting
我的观点 :
<div class="container">
<form class="form-signin" method="post" action="">
<h2 class="form-signin-heading">Admin Login</h2>
<input type="text" id="inputUsername" name ="inputUsername"
class="form-control" placeholder="Admin" required autofocus />
<label for="inputPassword" class="sr-only"> Password</label>
<input type="password" id="inputPassword" name="inputPassword"
class="form-control" placeholder="Password" required />
<br/>
<button class="btn btn-lg btn-primary btn-block" name="login"
type="submit">Login</button>
</form>
</div>
我的控制器:
if (isset($_POST['login'])) {
$username = $_POST['inputUsername'];
$password = $_POST['inputPassword'];
echo "<script>window.location.href = 'collections.php';</script>";
}
当我单击按钮时,它不会将我重定向到collections.php,我在这里错过了什么?
使用php标头来重定向页面,这与您在此处所做的操作简单而又完善。 header('Location: http : //www.example.com/ ');
你从PHP重定向
<?php
if (isset($_POST['login'])) {
$username = $_POST['inputUsername'];
$password = $_POST['inputPassword'];
header('Location: collections.php'); //<------- php redirect to other page
}
?>
这是您尝试在PHP中输出JS进行重定向的方式,如果使用相对
$redirectURL = "../controller/collection.php";
print("<script>");
print("var t = setTimeout(\"window.location='".$redirectURL."';\", 3000);");
print("</script>");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.