登录表单根据密码将用户指向多个页面

时间:2014-05-25 19:39:11

标签: javascript php jquery login

有人可以告诉我如何设置下面的表单以登录与密码同名的不同页面。例如用户名: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:&nbsp;</strong>
    <input type="password" name="password2" size="15">
  </p>
    <div align="center">
      <input type="button" value="Submit" onclick="submitentry()" />
    </div>
</blockquote>
</blockquote>

2 个答案:

答案 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:&nbsp;</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;
}