What alternative solution can be used to pass variables like $sepp to a PHP function when handling button click events?

When handling button click events in PHP, you can't directly pass variables like $sepp to a function. One alternative solution is to use HTML data attributes to store the value and then retrieve it using JavaScript when the button is clicked. This way, you can pass the variable to the PHP function through an AJAX request.

<button class="btn" data-sepp="<?php echo $sepp; ?>">Click me</button>

<script>
document.querySelector('.btn').addEventListener('click', function() {
    var sepp = this.getAttribute('data-sepp');
    
    // Make an AJAX request to pass the variable to a PHP function
    var xhr = new XMLHttpRequest();
    xhr.open('POST', 'your_php_file.php', true);
    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xhr.send('sepp=' + sepp);
});
</script>