Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#ifndef SELECT_DB_H | ||
#define SELECT_DB_H | ||
#include <iostream> | ||
#include <string> | ||
#include <vector> | ||
#include "libsqlite.hpp" | ||
#include "insert_db.h" | ||
using namespace std; | ||
|
||
class select_db | ||
{ | ||
protected: | ||
string modules; | ||
string classes; | ||
int students, studentID; | ||
string lecturers, rooms; | ||
string name, surname, username, email, password, retry, log1, pass1; | ||
int Timing; | ||
int Term; | ||
public: | ||
select_db(){ | ||
try | ||
{ | ||
sqlite::sqlite db("School.db"); | ||
|
||
auto cur = db.get_statement(); | ||
cur->set_sql("SELECT username,password FROM STUDENTDETAILS WHERE username=? AND password=?;"); | ||
cur->prepare(); | ||
cur->bind( 1, username ); | ||
cur->bind( 2, password ); | ||
|
||
string sqlusername; | ||
string sqlpassword; | ||
|
||
while (cur->step()){ | ||
sqlusername=cur->get_str(0); | ||
sqlpassword=cur->get_str(1); | ||
|
||
} | ||
|
||
} | ||
if sqlusername == null or sqlpassword==null: | ||
return "invalid" | ||
return sqlusername,sqlpassword; | ||
} | ||
catch( sqlite::exception e ) | ||
{ | ||
cerr << e.what() << endl; | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
}; | ||
|
||
#endif |