<?php
session_name("vadmin_session");
session_start();
include('connection.php');
if(isset($_POST['submit'])){
    $adminuser = mysqli_real_escape_string($conn, $_POST['adminuser']);
    $adminpass = mysqli_real_escape_string($conn, $_POST['adminpass']);
    $adminanswer = mysqli_real_escape_string($conn, $_POST['adminanswer']);
    
    $query = "SELECT * FROM v_admin WHERE BINARY username='$adminuser' AND BINARY password='$adminpass' AND BINARY answer='$adminanswer'";
    $res = mysqli_query($conn, $query);
    
    if (mysqli_num_rows($res) > 0) {
        if ($row = mysqli_fetch_array($res)) {
            $_SESSION['vname'] = $row['username'];
    
            header("location:dashboad.php");
        }
    } else {
        header("Location: index.php?error=Incorrect User Name, Password, or Answer");
    }
}
else {
    header("Location: index.php?error=Something Went Wrong!");
}
?>
