What are potential ways to assign a responsible person to each page in a website using PHP?

Assigning a responsible person to each page on a website can be achieved by creating a database table that maps pages to users. Each time a user accesses a page, their user ID can be stored in the database alongside the page ID. This way, you can easily retrieve the responsible person for a specific page.

// Assuming you have a database connection established

// Function to assign a responsible person to a page
function assignResponsiblePerson($pageId, $userId) {
    global $conn;
    
    $stmt = $conn->prepare("INSERT INTO page_responsibilities (page_id, user_id) VALUES (?, ?)");
    $stmt->bind_param("ii", $pageId, $userId);
    $stmt->execute();
    $stmt->close();
}

// Function to get responsible person for a page
function getResponsiblePerson($pageId) {
    global $conn;
    
    $stmt = $conn->prepare("SELECT user_id FROM page_responsibilities WHERE page_id = ?");
    $stmt->bind_param("i", $pageId);
    $stmt->execute();
    $stmt->bind_result($userId);
    $stmt->fetch();
    $stmt->close();
    
    return $userId;
}