I want to create a registration function and I want to verify if a user name is already in my database. I do not know how to verify if "SELECT" statement returns NULL. This is what i wrote so far:
strcat(msg, "Insert username:\n");
if(write(client, msg, 100) <= 0)
{
perror("Error");
exit(1);
}
if(read(client, name, 30) <= 0)
{
perror("Error");
exit(1);
}
sqlite3_stmt *res;
char sql[100];
sprintf("SELECT * FROM users where name=\"%s\";", name);
int rc = sqlite3_prepare_v2(db, sql, -1, &res, NULL);
if(rc != SQLITE_OK)
{
perror("Error");
exit(1);
}
int step = sqlite3_step(res);
if(step != SQLITE_DONE)
{
perror("Error");
exit(1);
}
Aucun commentaire:
Enregistrer un commentaire