doing login logic. fix errors in database.php