How to assign registration codes on a form submission?