Logout and save form only if valid