What are some best practices for ensuring a form functions correctly even if JavaScript is disabled?

When JavaScript is disabled, it's important to ensure that the form still functions correctly. One way to achieve this is by using server-side validation with PHP to validate form inputs and handle form submissions. This ensures that the form can still be processed even without JavaScript.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Validate form inputs
    $name = $_POST["name"];
    $email = $_POST["email"];
    
    // Perform server-side validation
    if (empty($name) || empty($email)) {
        echo "Please fill out all fields";
    } else {
        // Process form submission
        echo "Form submitted successfully";
    }
}
?>