What are the potential risks of using radio buttons for data deletion in PHP forms?
Using radio buttons for data deletion in PHP forms can pose a security risk as it allows users to easily manipulate the form data and potentially delete unintended records. To mitigate this risk, it is recommended to use checkboxes instead of radio buttons for data deletion, as checkboxes allow for multiple selections and provide a clearer indication of the user's intent.
<form method="post" action="delete.php">
<?php
// Loop through records and display checkboxes for deletion
foreach ($records as $record) {
echo '<input type="checkbox" name="delete[]" value="' . $record['id'] . '"> ' . $record['name'] . '<br>';
}
?>
<input type="submit" value="Delete Selected Records">
</form>