Handle error and success on form submission