What are the potential pitfalls of using onchange functions in PHP forms?

Potential pitfalls of using onchange functions in PHP forms include relying on client-side scripting for validation, which can be bypassed by users with disabled JavaScript. To solve this issue, it is recommended to perform server-side validation in addition to any client-side validation.

// Server-side validation example
if(isset($_POST['submit'])){
    $input = $_POST['input'];
    
    // Validate input
    if(empty($input)){
        $error = "Input is required";
    } else {
        // Process the input
    }
}