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!";
}
?>
Keywords
Related Questions
- In the context of the PHP forum thread, what are the benefits of using classes like DateTime and DateInterval for handling dates and times?
- What are some best practices for sending emails with PHP to ensure delivery and receipt confirmation?
- What are the differences between using backticks and omitting quotes when referencing column names in SQL queries in PHP?