What is the recommended method to display values in a field after clicking a button in PHP?

When a button is clicked in PHP, you can use a form submission to send the data to the server and then display the values in a field on the same page. One way to achieve this is by using a combination of HTML form, PHP script to handle the form submission, and echoing the values back to the field in the HTML document.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $value = $_POST["value"]; // Retrieve the value from the form submission
    echo '<input type="text" value="' . $value . '">'; // Display the value in a text input field
}
?>

<form method="post">
    <input type="text" name="value">
    <button type="submit">Submit</button>
</form>