Form submission comes up with errors as logic not working