<?php
require("includes/dbconnect.php");
require("includes/config.php");
require("includes/function.php");

   $udbf = $zdbroot . "passmain";

    $login = mysqli_query($conn, "SELECT * FROM `passmain` WHERE `user` = '" . mysqli_real_escape_string($conn, $_POST['user']) . "'
                         AND `password` = '" . mysqli_real_escape_string($conn, $_POST['pass']) . "'") or die(mysqli_error($conn));

    $_SESSION["username_" . $dbname] = $login["user"];

    $_SESSION["zdbroot"] = $zdbroot;
    $_SESSION["zdir"] = $zdir;


    if (mysqli_num_rows($login) == 1) {
        $_SESSION['username_' . $dbname] = $_POST["user"];
        $_SESSION['logged-in'] = true;
        $getuser_dtl = mysqli_fetch_object($login);
        $admin = $getuser_dtl->admin;
        $_SESSION["admin_" . $dbname] = $admin;

        header("Location: year.php");
    } else {
        print '<script type="text/javascript">';
        print 'alert("Invalid Login Credentials")';
        //header('refresh: 1; index.php');
        print '</script>';
    }

?>