In the context of a PHP login script, why is it important to validate user inputs on the server side in addition to using client-side validation with JavaScript?

It is important to validate user inputs on the server side in addition to using client-side validation with JavaScript because client-side validation can be bypassed by users who disable JavaScript or manipulate the code. Server-side validation ensures that data is validated and sanitized before it is processed, preventing potential security vulnerabilities such as SQL injection or cross-site scripting attacks.

// Server-side validation example
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $username = $_POST['username'];
    $password = $_POST['password'];
    
    // Validate inputs
    if (empty($username) || empty($password)) {
        echo "Please fill in all fields.";
    } else {
        // Process login
    }
}