<?php 
require_once('includes/config.php');
require_once('session.php');
?>

<?php

//portal login
$username = trim($_POST['username']);
$password = md5(trim($_POST['password']));


$query=mysqli_query($conn,"SELECT * FROM users WHERE username = '$username' and password = '$password'");

$fsel = mysqli_fetch_array($query);
$dbuser = $fsel['username'];
$dbpass = $fsel['password'];


if ($dbuser == $username && $dbpass == $password){
	?>
    <script>
alert("Access Granted!\n\nPlease proceed to the dashboards");	
window.parent(location="welcome.php");
	</script>
    <?php 
   
	}


else{
	
//auth failed
	
	?>
<script>
alert("Invalid Login Details!!\n\nPlease try login again")	
window.parent(location="sign-in.php");
</script>
<?php
	}
?>

