login checks, db insertion and query for login