Sir, please help me to locate the error, if user not found or wrong user name password etc then all codes work fine but when I enter correct user name and password then no result.
<?php
session_start();
require_once("includes/connect.php");
require_once("includes/functions.php");
if(isset($_POST['login']))
{
$muser=clean($_POST['username']);
$mpass=clean($_POST['password']);
if(empty($muser))
{
echo ('<script type="text/javascript">alert("User name must not be empty")</script>');
}
elseif (empty($mpass))
{
echo ('<script>alert("Password must not be empty")</script>');
}
else
{
$query1="SELECT * FROM admin where user ='". $muser ."' ";
$result1=mysqli_query($con,$query1)or die ("Error". mysqli_error($con)) ;
$count1=mysqli_num_rows($result1);
if($count1==0)
{
echo ('<script>alert("User not found")</script>');
}
else
{
$query="SELECT * FROM admin where user ='".$muser."' and pass='".$mpass."'";
echo 'Query='. $query;
$result=mysqli_query($con,$query)or die ("Error". mysqli_error($con)) ;
$row=mysqli_fetch_array($result);
$count=mysqli_num_rows($result);
if($count==0)
{
echo '<script>alert("Password is invalid")</script>';
}
else
{
echo '<script>alert("Password matched")</script>';
header("location: index.php");
$_SESSION['id'] = $row['id'];
$_SESSION['user'] = $myusername;
$_SESSION["startTime"] = date("r");
}
}
}
}
?>