register and login function complete