User registration working.

Checks for existing usernames and also adds new users to the database.