有人可以告诉我如何设置下面的表单以登录与密码同名的不同页面。例如用户名:David密码:Customer1
然后,这会将用户引导至customer1.html。
和用户名:Steve密码:customer8,将用户定向到customer8.html。我记得在几年前看过一个使用Javascript的教程,但我现在找不到任何关于如何做的事情。
提前致谢。
<form name="password1">
<blockquote>
<blockquote>
<p align="center">Client Login</p>
<p><strong>Username: </strong>
<input type="text" name="username2" size="15">
<br>
<strong>Password: </strong>
<input type="password" name="password2" size="15">
</p>
<div align="center">
<input type="button" value="Submit" onclick="submitentry()" />
</div>
</blockquote>
</blockquote>
答案 0 :(得分:0)
正如评论&amp;因为你在问题中标记了PHP,所以我为你提供了一个基于服务器的解决方案。
<强>的index.html 强>
<form name="password1" action="check.php" method="POST">
<blockquote>
<p align="center">Client Login</p>
<p><strong>Username: </strong>
<input type="text" name="username2" size="15">
<br>
<strong>Password: </strong>
<input type="password" name="password2" size="15">
</p>
<div align="center">
<input type="submit" value="Submit" />
</div>
</blockquote>
</form>
<强> check.php 强>
<?php
if(isset($_POST['password2'])){
$password = stripslashes($_POST['password2']);
$password = mysqli_real_escape_string($password);
// You may verify whether the username & password entered matches with database or not
$address = "$password".".html";
header("location: $address");
}
?>
答案 1 :(得分:0)
在check.php中
选择您的用户名&amp;用于检查的密码。
使用IF ELSE使其正常工作。
if($password = 'customer1')
{
header("location: customer1.html");
exit;
}
.
.
.
else if($password = 'customer8')
{
header("location: customer8.html");
exit;
}