<?php
session_start();
include('../include/config_animal.php');

$username = $_POST['username'];
$password = $_POST['password'];

if(empty($username)){
echo 'Enter Credentials';
exit();
}

$sql=mysqli_query($con,"SELECT username from admin WHERE username='$username'");
$check=mysqli_num_rows($sql);
if($check!=0 )
{  

$result = mysqli_query($con,"SELECT * FROM admin WHERE username='$username'");
while($row=mysqli_fetch_assoc($result)){

	$pass=$row['password'];
    
    $name=$row['name'];
    $phone=$row['phone'];
    $role=$row['role'];
    $page_title=$row['page_title'];
    $logo=$row['logo'];
		
	
}

if($password==$pass){		
			  		

                            // Store data in session variables
                            $_SESSION["online_ed_pharma_admin_login"] = true; 
                            $_SESSION["online_ed_pharma_admin_password"] = $pass;
                            $_SESSION["online_ed_pharma_admin_name"] = $name;
                            $_SESSION["online_ed_pharma_admin_role"] = $role;     
                            $_SESSION["online_ed_pharma_admin_page_title"] = $page_title;            
                            $_SESSION["online_ed_pharma_admin_page_logo"] = $logo;                         
			   

                            // Redirect user to welcome page                          
                          
                           echo "<script>window.location.href='Dashboard/index.php';</script>";


}

else{
                            // Display an error message if password is not valid
                            echo "Wrong Password Entered";
			
                        }

}
else{
                    // Display an error message if username doesn't exist
                    echo "Wrong Username Entered";
                }

?>
