<?php
session_start(); // Start the session
include("connection.php");

if (isset($_POST['Submit'])) {
    $AccID = $_POST['AccID'];
    $AccPass = $_POST['AccPass'];
    $AccAdminID = $AccID;

    $sql = "SELECT * FROM renter WHERE Renter_ID = '$AccID' AND Renter_Pass = '$AccPass'";
    $query = mysqli_query($conn, $sql);
    $column = mysqli_num_rows($query);

    if ($column == 0) {
        $sql = "SELECT * FROM admin WHERE Admin_ID = '$AccID' AND Admin_Pass = '$AccPass'";
        $query = mysqli_query($conn, $sql);
        $column = mysqli_num_rows($query);

        if ($column == 0) {
            echo "<script>alert('ID Or Password is incorrect')</script>";
            echo "<script>window.location = 'login.html'</script>";
            exit();
        } else {
            $_SESSION['AccAdminID'] = $AccAdminID;
            echo "<script>window.location = 'adminmenu.php'</script>";
            exit();
        }
    } else {
        $_SESSION['AccID'] = $AccID;
        echo "<script>window.location = 'rentermenu.php'</script>";
        exit();
    }
}
?>
