Finished register controller, added ajax pre-wrap

Finished beta register-by-invite controller, added ajax-pre-wrap and
couple of small mysql and security fixes