Migrating mysql functions to mysqli, cleanup

Moving database-y stuff over to non-deprecated functions.
Significant cleanup of login and register.