<?php
include('include/headscript.php');
$conn = new mysqli($servername, $username, $password, $database);

if ($conn->connect_error) {
    die("Errore di connessione: " . $conn->connect_error);
}

if (isset($_GET['idrole'])) {
    $idrole = intval($_GET['idrole']);

    $query = "DELETE FROM sharing_roles WHERE idrole = ?";
    $stmt = $conn->prepare($query);
    $stmt->bind_param('i', $idrole);

    if ($stmt->execute()) {
        header("Location: sharing-roles.php?success=true");
    } else {
        header("Location: sharing-roles.php?error=true");
    }

    $stmt->close();
}
$conn->close();
