How can PHP be integrated into static HTML pages for features like contact forms?

To integrate PHP into static HTML pages for features like contact forms, you can create a separate PHP file to handle the form submission and processing. In the HTML form, set the action attribute to point to the PHP file. The PHP file will receive the form data using $_POST or $_GET, process it, and send a response back to the user.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    
    // Process the form data here
    
    // Send a response back to the user
    echo "Thank you for your message!";
}
?>