working code - login and reg