What potential problem is highlighted in the code snippet related to the DELETE query and how can it be resolved?

The potential problem highlighted in the code snippet is the lack of input validation and sanitization in the DELETE query. This leaves the application vulnerable to SQL injection attacks. To resolve this issue, input should be properly sanitized before being used in the query to prevent malicious code execution.

// Sanitize the input before using it in the DELETE query
$id = filter_var($_POST['id'], FILTER_SANITIZE_NUMBER_INT);

// Prepare and execute the DELETE query
$stmt = $pdo->prepare("DELETE FROM table_name WHERE id = :id");
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
$stmt->execute();