<?php
// Include the database connection file
require_once 'connection.php';

// Check if email parameter is provided
if (isset($_GET['email'])) {
    $email = trim($_GET['email']);
    
    // Delete user from the database by email
    $sql = "DELETE FROM user WHERE email = '$email'";
    $result = $conn->query($sql);

    if ($conn->affected_rows > 0) {
        // User deleted successfully
        $response = array(
            "status" => "success",
            "message" => "User with email $email deleted successfully"
        );
    } else {
        // No user found with the provided email
        $response = array(
            "status" => "error",
            "message" => "User not found with email: $email"
        );
    }
} else {
    // No email parameter provided
    $response = array(
        "status" => "error",
        "message" => "Email parameter is required"
    );
}

header('Content-Type: application/json');
echo json_encode($response);

$conn->close();
?>
