<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);

	session_start(); // Starting Session
	$error=''; // Variable To Store Error Message
	if (isset($_POST['submit'])) {
	if (empty($_POST['username']) || empty($_POST['password'])) {
	$error = "Username or Password is not valid";
	}else{
		include ('dbConnect.php');
		// Define $username and $password
		$username=$_POST['username'];
		$password=$_POST['password'];
		
		// To protect MySQL injection for Security purpose
		$username = stripslashes($username);
		$password = stripslashes($password);
		//$username = mysql_real_escape_string($username);
		//$password = mysql_real_escape_string($password);
		
		// SQL query to fetch information of registerd users and finds user match.
		$usql="select * from Admins where password='$password' AND username='$username'";
		$result = mysqli_query($hookup, $usql);
		$rows = mysqli_num_rows($result);
		if ($rows >= 1) {
		$_SESSION['login_user']=$username; // Initializing Session
		header("location: index.php"); // Redirecting To Other Page
		
		} else {
			$error = "Username or Password is invalid";
		}
		
		}
	}
?>