<?php
	session_start();
	include 'includes/conn.php';

	if(isset($_POST['login'])){
		$username = $_POST['username'];
		$password = $_POST['password'];
 
		$sql = "SELECT * FROM admin WHERE username = '$username' and password='$password'";
		$query = $conn->query($sql);

		if($query->num_rows == 0){
		echo '<script>window.location.href = "home.php";</script>';
        exit;
		
		}
		else{
		$row = $query->fetch_assoc();
		$_SESSION['admin'] = $row['id'];
		echo '<script>window.location.href = "home.php";</script>';
        exit;
	    
			
		}
		
	}
	else{
		$_SESSION['error'] = 'Input admin credentials first';
		echo '<script>window.location.href = "index.php";</script>';
        exit;
	}


?>