`
$host="localhost";
$dbuser="root";
$pass="";
$dbname="project";
$conn=mysqli_connect($host,$dbuser,$pass,$dbname);
if(mysqli_connect_errno())
{
die("Connection Failed! :" . mysqli_connect_error());
}
if (isset($_POST['submit'])){
$username=$_POST['username'];
$password=$_POST['password'];
//Checking is user existing in the database or not
$query = "SELECT * FROM login WHERE username='$username' and password='$password'";
$result = mysqli_query($conn,$query) or die(mysqli_error($conn));
$rows = mysqli_num_rows($result);
if($rows>0){
$_SESSION['username'] = $username;
header("Location: nlogin.php"); // Redirect user to index.php
}else{
?>
<h1 style="color:white">Username/password is incorrect.</h1>
<?php
}
}
?>`
Here I have to make it to connect to Login Page and match password in database but it always go to else block "Incorrect Password"