<?php
    include_once "../../backend/connection.php";
    session_start();
    $conf = new DefaultDatabase();

    $configure = $conf->connect();

    if($_SERVER["REQUEST_METHOD"]=="POST")
    {
        $username = htmlentities($_POST["username"]);
        $password = md5($_POST["password"]);

        $login = mysqli_query($configure,"SELECT COUNT(*) AS possible FROM adjudicator where username = '".$username."' AND password = '".$password."'");

        $possible = mysqli_fetch_assoc($login);

        if($possible["possible"] < 1)
        {
            echo(
                "
                <script>
                    alert('Incorrect Username or Password');
                    window.location.href='../index.php';
                </script>
                "
            );
        }
        else
        {

            $_SESSION["judge_admin"] = $username;
            header("location:../home.php");
        }
        
    }
?>