创建客户登录区域。我在 clientLogin.html 中有我的登录表单:
<form name="ClientLogin" method="post" action="login.php"> <br>
<p>
<label for='Username'>Username</label> <br>
<input type="text" name="username" />
</p>
<p>
<label for='Password'>Password</label> <br>
<input type="password" name="password" />
</p>
<br>
<input type="submit" value="Submit" />
</form>
如果用户名和密码组合不正确,我想重定向到此页面,并添加一条消息“用户名/密码不正确,请重试”。这是 login.php 中的代码:
<?php
//Connect to the database
require('db.php');
$user = mysql_real_escape_string($_POST["username"]);
$pass = mysql_real_escape_string($_POST["password"]);
$clientdata = mysql_query("SELECT * FROM Users WHERE username='$user' and password='$pass'")
or die (mysql_error());
$data = mysql_fetch_array($clientdata, MYSQL_ASSOC);
if(mysql_num_rows($clientdata) == 1){
session_start();
$_SESSION['username'] = $user;
header('Location: profile.php');
}else{
header('Location: clientLogin.html');
}
我希望 clientLogin.html 文件需要更改为 .php 文件。除此之外,我很难过。任何指导将不胜感激。