Finished php code to allow users to login to allow users to login. Tested it myself, code is robust.