当有人输入错误的用户名或密码时,我想突出显示红色的登录框,但它给了我一个失败的方面。
我是怎么做的:
HTML
<div class="login">
<form action="" method="post" name="login">
<input type="text" name="username" placeholder="Username" required />
<input type="password" name="password" placeholder="Password" required />
<input type="image" src="https://i.imgur.com/uVoJ8Kl.pngg" />
</form>
</div>
PHP
<?php
require('config.php');
session_start();
// If form submitted, insert values into the database.
if (isset($_POST['password'])){
$username = $_POST['username'];
$password = $_POST['password'];
$username = stripslashes($username);
$username = mysql_real_escape_string($username);
$password = stripslashes($password);
$password = mysql_real_escape_string($password);
//Checking is user existing in the database or not
$query = "SELECT * FROM `users` WHERE username='$username' and password='".sha1($password)."'";
$result = mysql_query($query) or die(mysql_error());
$rows = mysql_num_rows($result);
if($rows==1){
$_SESSION['username'] = $username;
header("Location: profile.php"); // Redirect user to index.php
}else{
echo "<div class='form'><h3>Username sau parola gresita. Click</h3><br/>Click <a href='login.php'>aici</a> pentru a reveni la pagina de login</div>";
}
}else{
}
?>
你能给我一个如何解决的提示吗?