What are best practices for displaying user input from one page to another in a PHP-based questionnaire?

When displaying user input from one page to another in a PHP-based questionnaire, it is best practice to use sessions to store the input data temporarily. This ensures that the data is available across different pages until it is no longer needed. By using sessions, you can easily retrieve and display the user input on subsequent pages without losing any information.

// Start the session
session_start();

// Store user input in session variables
$_SESSION['input1'] = $_POST['input1'];
$_SESSION['input2'] = $_POST['input2'];

// Retrieve and display user input on another page
echo "Input 1: " . $_SESSION['input1'];
echo "Input 2: " . $_SESSION['input2'];