如果登录代码经过验证,我应该进入成员页面,否则我应该说在同一页面上。。我不知道如何编写指向另一个页面的导航链接。。我看到了一些使用标题的答案,但我没有得到。
login.php
if($username==$dbusername&&$password==$dbpassword)
{
// If this condition is true I should go into member page
}
else
{
echo "incorrect password!"; //should stay in the same page
}
form action= "member.php" method="post"
Username: input type="text" name="username"<br/>
Password: input type="password" name="password"<br/>
input type="submit" value="LogIn"><br/><br/>
只需像这样使用header
:
if($username==$dbusername&&$password==$dbpassword)
{
header("location:member.php");
}
如果你想在重定向中延迟,你可以使用这个:
header("Refresh: 5;url=klanten.php");
(重定向前将等待5秒)
您想要做的事情可以通过发布到同一页面login.php 来实现
在任何html之前,请检查:
if (isset($_POST['username'])) {
if($username==$dbusername && $password==$dbpassword) {
header("location: member.php");
}
}
header("location:member.php")如果条件为true,则简单地重定向到member.php。所以表格看起来像这样:
form action="login.php" method="post">
Username: <input type="text" name="username" />
Password: <input type="password" name="password" />
<input type="submit" value="LogIn" />
</form>