When I use my login form, it states that there is not user however my login details are correct. I can't seem to see what's up in the form. Thank you for your help!
<?php
include("connect.php");
if(isset($_POST['submit'])){
$username=$_POST['username'];
$password=$_POST['password'];
//Protect MySQL Injection
$username=stripcslashes($username);
$username=mysqli_real_escape_string($username);
$username=htmlspecialchars($username);
$password=stripcslashes($password);
$password=mysqli_real_escape_string($password);
$password=htmlspecialchars($password);
//Run Query to Database
$sql="SELECT * FROM officers WHERE username='$username' AND password='$password'";
$result=mysqli_query($sql);
//Counting Numbers of MySQL row [if user Found row must be 1]
$row=mysqli_num_rows($result);
//Fetching User Informaiton from Database
$userinfo=mysqli_fetch_assoc($result);
$role=$userinfo['role'];
if($row==1){
//Initilizing SESSION with Differents user Role
$_SESSION['login_user']=$username;
$_SESSION['role']=$role;
if($role=='admin'){
header('location:admin.php');
}
if($role=='user'){
header('location:user.php');
}
}else{
echo "No User Found by Given Information";
}
}
?>