How can one troubleshoot the issue of receiving the error message "Das Alte Passwort ist falsch" even when the form fields for password change are left blank in the PHP script?

The issue of receiving the error message "Das Alte Passwort ist falsch" (The old password is incorrect) when the form fields for password change are left blank in the PHP script can be solved by adding a condition to check if the old password field is empty before validating it. If the old password field is empty, the validation should be skipped.

if(isset($_POST['submit'])){
    $oldPassword = $_POST['old_password'];
    $newPassword = $_POST['new_password'];
    
    if(!empty($oldPassword)){
        // Validate old password and change password logic here
    } else {
        // Skip validation if old password field is empty
    }
}