<?php
header("Content-Type: application/json");

// Allow DELETE method
if ($_SERVER['REQUEST_METHOD'] !== 'DELETE') {
    http_response_code(405); // Method Not Allowed
    echo json_encode(["message" => "Invalid request method."]);
    exit;
}

// Parse the JSON body
$input = json_decode(file_get_contents("php://input"), true);

// Check if email and password are provided and not empty
if (!isset($input['email']) || empty(trim($input['email'])) || 
    !isset($input['password']) || empty(trim($input['password']))) {
    http_response_code(400); // Bad Request
    echo json_encode(["message" => "Email and password are required and cannot be empty."]);
    exit;
}

$email = trim($input['email']);
$password = trim($input['password']);

// Mock condition for email not registered
if (true) { 
    http_response_code(200); // OK
    echo json_encode(["message" => "Your email is not registered."]);
} else {
    http_response_code(500); // Internal Server Error
    echo json_encode(["message" => "Failed to delete account. Please try again."]);
}

?>
