What are the best practices for extending a PHP contact form with new fields like phone number, age, and topic?

To extend a PHP contact form with new fields like phone number, age, and topic, you need to update both the HTML form and the PHP script handling the form submission. Add the new input fields to the HTML form with appropriate labels and validation rules. In the PHP script, retrieve the values of the new fields from the $_POST array and process them accordingly.

<form method="post" action="process_form.php">
    <label for="phone">Phone Number:</label>
    <input type="text" id="phone" name="phone" required>
    
    <label for="age">Age:</label>
    <input type="number" id="age" name="age" required>
    
    <label for="topic">Topic:</label>
    <input type="text" id="topic" name="topic" required>
    
    <!-- existing form fields here -->
</form>
```

```php
<?php
// process_form.php

$fullname = $_POST['fullname'];
$email = $_POST['email'];
$message = $_POST['message'];
$phone = $_POST['phone'];
$age = $_POST['age'];
$topic = $_POST['topic'];

// Process the form data as needed
// For example, send an email with the form details