<?php
session_start();
require_once "SqlConnection/MySqlConnection.php";
if (isset($_POST['email'])){
    $email = $_POST['email'];
    $password = $_POST['password'];
    $type = $_POST['type'];    
    $sql = "SELECT * FROM login WHERE email='".$email."' AND password='".$password."' AND type='admin' LIMIT 1"; 
    $result = mysqli_query($conn,$sql);
    if (mysqli_num_rows($result)==1){
        $userID="";                                                
        while ($row = mysqli_fetch_array($result)) {
            $userID = $row['id'];           
        }                        
        $_SESSION['userID'] = $userID;

        //this is for selecting current option like dashboard will be 1 and invoice option will be 2 and so on...
        $_SESSION['focus'] = 1;
        header("Location: index.php");
        exit();
    }
    else{
        header("Location: sign-in.php");
        exit();
    }
}
?>
