<?php

require('../includes/config.php');
session_start();

if (isset($_POST['username'])){
    
	// removes backslashes
	$username = stripslashes($_POST['username']);
	$password = stripslashes($_POST['password']);

	$sql = 'SELECT * from users where id="1"';
	$result = mysqli_query($conn, $sql);
	$row = $result->fetch_row();

	if ( $username == $row['1'] ) {
		
		if ( $password == $row['3'] ){
			
			$_SESSION['username'] = $username;
			header("Location: admin.php");		
		
		}
		else {
			header("Location: index.php");
		}
	}
	else {
		header("Location: index.php");
	}

 
}
else{
	header("Location: index.php");
} 
?>