获取到用户名与密码后,与数据库中的用户名与密码做个比较。
打开user.db,重要是这两句代码:要了解sql语句的使用。
sprintf(sql,"select passwd from users where email='%s'",username);
ret = sqlite3_get_table(db,sql,&dbresult,&nrow,&ncolumn,&errmsg);
int check_user(char *name ,char *password)
{
sqlite3 *db = NULL;
char *errmsg = NULL;
char sql[256];
int ret = 0;
char **dbresult;
int nrow;
int ncolumn;
#ifdef DEBUG
int index;
int i ,j;
#endif
ret = sqlite3_open("../db/user.db",&db);
if(ret != SQLITE_OK)
{
perror("fail to open user.db:n");
return -2;
}
memset(sql,0,256);
sprintf(sql,"select passwd from users where email='%s'",username);
ret = sqlite3_get_table(db,sql,&dbresult,&nrow,&ncolumn,&errmsg);