I have created a login page for a website. the code of the form and its backend code is on the same page
View of db table is
id email password status block
1 vendor@gmail.com vendor vendor active
2 ABC@gmail.com ABC vendor inactive
Code for form is
$myemail = mysqli_real_escape_string($con, $_POST['email']);
$mypassword = mysqli_real_escape_string($con, $_POST['password']);
$sql = "SELECT id FROM register WHERE email='$myemail' and password='$mypassword' and status='vendor' and block='inactive'";
$result = mysqli_query($con, $sql);
if (mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result))
{
$_SESSION['login_user']= $row["email"];
header("location: vendorpanel.php");
}
}
else
{
$error="Your Login Name or Password is invalid";
}
}
?>
<form class="login-form" action="" method="POST">
<h1>Login Form</h1>
<div>
<input type="text" placeholder="email" required="" id="email" name="email" />
</div>
<div>
<input type="password" placeholder="Password" required="" id="password" name="password"/>
</div>
<div>
<input type="submit" value="Log in" name="submit" />
<!--<a href="#">Lost your password?</a>
<a href="#">Register</a>-->
</div>
</form>
The login code works fine, but I would like to display 2 types of error as a pop up box.
1) the first error is if the password is wrong then it should display a password error
2) the second error is if the block parameter is active then the user should get a message that his account has been blocked
can anyone tell how I can do so.