<?php
include('connection.php');

if (isset($_GET['id'])) {
    $teleId = $_GET['id'];
    
    // Perform the DELETE operation in your database
    $sql = "DELETE FROM telegram WHERE id = $teleId";
    $result = mysqli_query($conn, $sql);

    if ($result) {
        // Redirect back to the page where contacts are displayed with a success message
        header("Location: add_telegram.php?success=Contact deleted successfully.");
        exit();
    } else {
        // Redirect back to the page with an error message if the deletion fails
        header("Location: add_telegram.php?error=Failed to delete contact.");
        exit();
    }
} else {
    // Handle the case where 'id' is not set in the URL
    header("Location: add_telegram.php?error=Contact ID not provided.");
    exit();
}
?>
