<?php
session_start();
require('../includes/database.php');

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

$query = "SELECT *
			FROM admin
			WHERE username = '$username'
			&&   password = '$password'";

$result = mysqli_query($con, $query) or die(mysqli_error());
$rows = mysqli_num_rows($result);
if ($rows == 1) {
	while ($data = mysqli_fetch_assoc($result)) {
		extract($data);
		$_SESSION["username"] = $username;
		$_SESSION["password"] = $password;
		header("Location:dashboard.php");
	}
} else {
	$_SESSION["message"] = 'Incorrect Username or Password';
	header("Location:index.php");
}
