added the login file, refactored a few php code

Added the login file, decently documented it, and fixed the register
conflicts when registering. I still have to deal with sessions, and
loging in after registering, which I will fix tomorrow.