<?php

error_reporting(0);
session_start();

require_once "../connection/db.php";

$user_id = $_SESSION['admin_user_id'] ?? '';
$password = $_SESSION['admin_password'] ?? '';

try {

	$db = getDB();

	$stmt = $db->prepare("
        SELECT member_id 
        FROM meddolic_user_details 
        WHERE user_id = ? 
        AND password = ? 
        AND user_type = 1
        LIMIT 1
    ");

	$stmt->execute([$user_id, $password]);
	$user = $stmt->fetch();

	if (!$user) {
		?>
		<script>
			window.top.location.href = "index.php";
		</script>
		<?php
		exit;
	}

} catch (PDOException $e) {
	die("Database Error: " . $e->getMessage());
}

?>