Why is the user with ID 12 being deleted in the script and how can this be improved for dynamic user deletion?

The issue with the current script is that it is hardcoding the deletion of user with ID 12, making it static and not dynamic. To improve this for dynamic user deletion, you can modify the script to accept a parameter for the user ID to be deleted.

// Assuming $user_id contains the ID of the user to be deleted
$user_id = $_POST['user_id']; // Example of getting user ID from POST data

// Connect to database and execute query to delete user with the specified ID
$pdo = new PDO('mysql:host=localhost;dbname=database_name', 'username', 'password');
$sql = "DELETE FROM users WHERE id = :user_id";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':user_id', $user_id, PDO::PARAM_INT);
$stmt->execute();