How can PHP code be used to retrieve and display form data submitted using the post method?

To retrieve and display form data submitted using the post method in PHP, you can use the $_POST superglobal array. This array contains key-value pairs of all the form data submitted via the post method. You can access the form data by using the name attribute of the form input fields as keys in the $_POST array.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = $_POST['name'];
    $email = $_POST['email'];
    
    echo "Name: $name <br>";
    echo "Email: $email";
}
?>