daily pastebin goal
66%
SHARE
TWEET

Untitled

a guest Apr 26th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <sqlite3.h>
  4.  
  5. using namespace std;
  6.  
  7.  int callback(void *data, int argc, char **argv, char **azColName){
  8.    string  userName = "admin";
  9. string passWord = "passw0rd";
  10. string sortCode = "202020";
  11.    
  12.    if(userName == argv[1]  && passWord == argv[2] && sortCode == argv[3])
  13.     {
  14.     cout << " MATCH TO DATABASE " << endl;
  15.     //flag to send cookie
  16.      cout << userName << passWord << sortCode << endl;
  17.  }
  18.    
  19.    
  20.    printf("\n");
  21.    return 0;
  22. }
  23.  
  24. int main(int argc, char* argv[]) {
  25.    sqlite3 *db;
  26.    char *zErrMsg = 0;
  27.    int rc;
  28.    char *sql;
  29.    const char* data = "Callback function called";
  30.  
  31.    /* Open database */
  32.    rc = sqlite3_open("/usr/lib/cgi-bin/bank.db", &db);
  33.    
  34.    if( rc ) {
  35.       fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
  36.       return(0);
  37.    } else {
  38.       fprintf(stderr, "Opened database successfully\n");
  39.    }
  40.  
  41.    /* Create SQL statement */
  42.    sql = "SELECT * FROM BANK WHERE username = '";
  43. sql.append(userName);
  44. sql.append("'");
  45.  
  46.    /* Execute SQL statement */
  47.    rc = sqlite3_exec(db,sql.c_str(),callback, (void*)data, &errMsg);
  48.    
  49.    if( rc != SQLITE_OK ) {
  50.       fprintf(stderr, "SQL error: %s\n", zErrMsg);
  51.       sqlite3_free(zErrMsg);
  52.    } else {
  53.       fprintf(stdout, "Operation done successfully\n");
  54.    }
  55.    sqlite3_close(db);
  56.    return 0;
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top