What are the best practices for passing variables to a PHP function called by a button in a different file?

When passing variables to a PHP function called by a button in a different file, it is best practice to use either GET or POST methods to send the data. GET method appends the data to the URL, while POST method sends the data in the background. To access the passed variables in the receiving PHP file, use $_GET or $_POST superglobals depending on the method used.

// Sending file (sender.php)
<form action="receiver.php" method="GET">
    <input type="hidden" name="variable_name" value="variable_value">
    <button type="submit">Submit</button>
</form>

// Receiving file (receiver.php)
<?php
if(isset($_GET['variable_name'])){
    $variable = $_GET['variable_name'];
    // Use the variable in your PHP code
}
?>