What are the potential security vulnerabilities in the PHP code provided for editing and deleting database entries?

The potential security vulnerabilities in the provided PHP code for editing and deleting database entries include SQL injection attacks, lack of input validation, and insufficient user authentication checks. To address these issues, it is crucial to use prepared statements with parameterized queries, validate user input to prevent malicious data entry, and implement proper authentication mechanisms to ensure that only authorized users can edit or delete entries.

// Fix for editing database entries with prepared statements
if(isset($_POST['edit_entry'])) {
    $entry_id = $_POST['entry_id'];
    $new_entry_data = $_POST['new_entry_data'];

    $stmt = $pdo->prepare("UPDATE entries SET data = :data WHERE id = :id");
    $stmt->execute(['data' => $new_entry_data, 'id' => $entry_id]);
}

// Fix for deleting database entries with prepared statements
if(isset($_POST['delete_entry'])) {
    $entry_id = $_POST['entry_id'];

    $stmt = $pdo->prepare("DELETE FROM entries WHERE id = :id");
    $stmt->execute(['id' => $entry_id]);
}