added better functionality to register/login submit (error and redirect)