I am very new to sqlite , please help me out the username and password are passed as arguments and I have already stored the password to a corresponding username in the table name as CREDENTIALS. How to check if the password is valid? Thanks
bool authenticateUser(string USER, string PASS)
{
sqlite3_stmt *pSelectStatement = NULL;
int iResult = SQLITE_ERROR;
bool ret = true;
insertQuery<<"SELECT * FROM CREDENTIALS WHERE USERID LIKE '"<<USER<<"' AND PASSWORD LIKE '"<<PASS<<"';";
iResult = sqlite3_prepare16_v2(db, insertQuery.str().c_str(), -1, &pSelectStatement, 0);
if ((iResult == SQLITE_OK) && (pSelectStatement != NULL))
{
iResult = sqlite3_step(pSelectStatement);
//was found?
if (iResult == SQLITE_DONE) {
ret = false;
sqlite3_clear_bindings(pSelectStatement);
sqlite3_reset(pSelectStatement);
}
iResult = sqlite3_finalize(pSelectStatement);
}
return ret;
}