<?php include("config.php");
include("config2.php");

$userid = isset($_SESSION['userid']) ? $_SESSION['userid'] : '';

if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

// Get permissions for this user
$sql = "SELECT permissions FROM user WHERE userid='$userid'";
$result = mysqli_query($conn, $sql);
if (!$result || mysqli_num_rows($result) == 0) {
    die("No permissions found for this user.");
}

$row = mysqli_fetch_assoc($result);
$permissions = explode(',', $row['permissions']); // array of allowed page names

function can_access($page_name, $permissions) {
    return in_array($page_name, $permissions);
}



if (can_access('bill_verify', $permissions)) { 
$bill_id = $conn->real_escape_string($_GET['id']);
$verify_s = $conn->real_escape_string($_GET['d']);
 
mysql_query("update restaurant_chalan set verify='$_SESSION[userid]', verify_s='$verify_s'  where  id='$bill_id'");
 }

mysqli_close($conn);
header("location:restaurant_bill_list.php");
?>