I found a solution I was looking for!
I removed the form tag from around the button, added #userModal id to the modal, and added data-id to the modal toggle button:
<button type="button" class="btn btn-primary userinfo" data-id='."$id".'>class="fas fa-user-edit"></button>
and used following javascript:
<script type="text/javascript">
$(document).ready(function(){
$('.userinfo').click(function(){
var id = $(this).data('id');
$.ajax({
url: 'admin_useredit.php',
type: 'post',
data: {id: id},
success: function(response){
$('.modal-body').html(response);
$('#userModal').modal('show');
}
});
});
});
</script>
where
admin_useredit.php
contains the dynamic output I'd like to see in the modal.
I used Bootstrap JS and jQuery libraries.