What are some best practices for handling form submission in PHP when using include to include PHP files?

When using include to include PHP files for form submission in PHP, it's important to ensure that the form submission logic is contained within the main PHP file that includes the form. This helps to keep the code organized and prevents potential issues with variable scope. To handle form submission effectively, you can check if the form has been submitted using isset($_POST['submit']) and then process the form data accordingly within the same PHP file.

// main.php

include 'form.php';

if(isset($_POST['submit'])){
    // Process form data
    $name = $_POST['name'];
    $email = $_POST['email'];

    // Perform validation and other necessary operations
    // Redirect or display success message
}
```
```php
// form.php

<form method="post" action="">
    <input type="text" name="name" placeholder="Name">
    <input type="email" name="email" placeholder="Email">
    <button type="submit" name="submit">Submit</button>
</form>