Skip to content
Permalink
30fceefdba
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
253 lines (214 sloc) 4.9 KB
#include <iostream>
#include <istream>
#include <stdio.h>
#include <stdlib.h>
#include <sqlite3.h> /*libraries*/
#include "insert_db.h"
#include "create_db.h"
#include "select_db.h"
using namespace std;
class student_data{
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:
string get_modules(){
return modules;
}
void change_modules(string _modules){
modules=_modules;
}
string get_classes(){
return classes;
}
void change_classes(string _classes){
classes=_classes;
}
int get_students(){
return students;
}
void change_students(int _students){
students=_students;
}
int get_studentID(){
return studentID;
}
void change_studentID(int _studentID){
students=_studentID;
}
string get_lecturers(){
return lecturers;
}
void change_lecturers(string _lecturers){
lecturers=_lecturers;
}
string get_rooms(){
return rooms;
}
void change_rooms(string _rooms){
rooms=_rooms;
}
string get_surname(){
return surname;
}
void change_surname(string _surname){
surname=_surname;
}
string get_username(){
return username;
}
void change_username(string _username){
username=_username;
}
string get_email(){
return email;
}
void change_email(string _email){
email=_email;
}
string get_password(){
return password;
}
void change_password(string _password){
password=_password;
}
string get_log1(){
return log1;
}
void change_log1(string _log1){
log1=_log1;
}
string get_pass1(){
return pass1;
}
void change_pass1(string _pass1){
pass1=_pass1;
}
string get_name(){
return name;
}
void change_name(string _name){
name=_name;
}
int get_Timing(){
return Timing;
}
void change_Timing(int _timing){
students=_timing;
}
int get_Term(){
return Term;
}
void change_Term(int _term){
Term=_term;
}
};
int showingthetimetable(){
return 0; // need to return 0/1 depending on the output
}
/*int secondentry(int len, char* value[]){login your details and check to see if they match the database
cout << "Please enter your student details to Login :" <<endl;
cout << "Username/Email :"; cin >> log1;
cout << "Password Please :" <<endl; cin >> pass1;
sqlite3 *db;
char *column = 0;
int load;
string sql;
load = sqlite3_open("School.db", &db);
if(load){
cout << "DB Error: " << sqlite3_errmsg(db) << endl;
sqlite3_close(db);
return(1);
}
sql = "SELECT password FROM STUDENTDETAILS " + username + ";";
load = sqlite3_exec(db, sql.c_str(), callback, 0, &column);
if (pass1 == sql){
cout << "Successfull Login" <<endl;
Timetablesforstudent();
}
else{
cout << "Please try again" <<endl;
secondentry();
}
return 0; // need to return 0/1 depending on the output
}
*/
int Timetablesforstudent(){
student_data s;
string stringtemp;
int inttemp;
cout << "Student ID"; cin >> inttemp;
s.change_studentID(inttemp);
cout << "modules :"; cin >> stringtemp;
s.change_modules(stringtemp);
cout << "classes :"; cin >> stringtemp;
s.change_classes(stringtemp);
cout << "students :"; cin >> inttemp;
s.change_students(inttemp);
cout << "lecturers :"; cin >> stringtemp;
s.change_lecturers(stringtemp);
cout << "rooms :"; cin >> stringtemp;
s.change_rooms(stringtemp);
cout << "Timing :"; cin >> inttemp;
s.change_Timing(inttemp);
cout << "Term :"; cin >> inttemp;
s.change_Term(inttemp);
return 1; // need to return something afterwards.
}
int login(){
student_data s;
string stringtemp;
cout << "Please enter your student details to Login :" <<endl;
cout << "Username/Email :"; cin >> stringtemp;
s.change_log1(stringtemp);
cout << "Password Please :" <<endl; cin >> stringtemp;
s.change_pass1(stringtemp);
Timetablesforstudent();
}
int signup(){
student_data s;
string stringtemp;
int inttemp;
string pass, retry;
cout << "Student ID"; cin >> inttemp;
s.change_studentID(inttemp);
cout << "Name :"; cin >> stringtemp;
s.change_name(stringtemp);
cout << "Surname :"; cin >> stringtemp;
s.change_surname(stringtemp);
s.change_username( s.get_surname() + s.get_name()[0]);
cout << "Enter your school email :"; cin >> stringtemp;
s.change_email(stringtemp);
cout << "Password :"; cin >> pass;
cout << "Enter Password again :"; cin >> retry;
if (pass == retry){
cout << "Password match";
stringtemp = pass;
s.change_password(stringtemp);
}
login();
}
int signuporlogin(){
int option;
menu:
cout << "[1] Sign Up" <<endl;
cout << "[2] Log In" <<endl;
cin >> option;
switch(option){
case 1:
signup();
break;
case 2:
login();
break;
}
}
int main() {
signuporlogin();
return 0;
}