$errors is only created if there is an actual error. if($errors) tests if the $errors variable contains a value other than false, but if no errors were generated, $errors is never created. There are two solutions.
- Make the first line of the script $errors=false; This will cause the script to work, because the if condition will fail if no errors are generated.
- Replace the if($errors) test with if(isset($errors)) which checks if the variable exists. Since the variable currently only gets created if there is an error, if $errors has not been created the test will fail.
Note, these are two ways of accomplishing the same task. Do not do both.