-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.cpp
104 lines (99 loc) · 2.91 KB
/
index.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include<bits/stdc++.h>
#include<mysql/mysql.h>
#include "sql_handler.h"
#include "file_opr.h"
#include "downloadFile.h"
#include "uploadFile.h"
#include "deleteData.h"
#include "updateFile.h"
namespace mysql_main
{
MYSQL * connect_obj=connect();
MYSQL_RES * res_set;
MYSQL_ROW row;
}
using namespace std;
void userMenu(int UserId, string username)
{
while(true){
cout<<"Welcome "+ username + "\n** Please Select a option **\n\t1. Upload File\n\t2. Download File\n\t3. Update File\n\t4. Delete File\n\t5. Delete Version\n\t6. Show My Uploaded Files\n\t7. Delete User\n\t8. Exit"<<endl;
int ch;
cin>>ch;
switch(ch)
{
case 1:
insertIntoUserFile(UserId);
break;
case 2:
DownloadFile(UserId);
break;
case 3:
update(UserId);
break;
case 4:
deleteFile(UserId);
break;
case 5:
deleteVersion(UserId);
break;
case 6:
cout<<"Files you have uploaded are :-"<<endl;
showFiles(UserId,1);
break;
case 7:
deleteUser(UserId);
break;
case 8:
cout<<"Bye..."<<endl;
exit(0);
break;
default:
cout<<"Invalid Input"<<endl;
break;
}
}
}
int main(int argc, char const *argv[])
{
int choice;
cout<<"Enter Choice:\n\t1.Login\n\t2.Register"<<endl;
cin>>choice;
if(choice==1)
{
string username;
string password;
cout<<"Enter Username: ";
cin>>username;
cout<<"Enter Password: ";
cin>>password;
string query="select userID from userTable where userName='"+username+"' and passwords='"+password+"';";
mysql_main::res_set=execute_query(mysql_main::connect_obj,query);
unsigned int numrows=mysql_num_rows(mysql_main::res_set);
int i=0;
if (numrows==0)
cout<<"You've entered incorrect username or Password\nTry again..."<<endl;
else
{
int userID,i=0;
while (((mysql_main::row=mysql_fetch_row(mysql_main::res_set)) !=NULL))
userID=atoi(mysql_main::row[i]);
cout<<"User ID: "<<userID<<endl;
userMenu(userID,username);
}
}
else
{
string username,email,password;
cout<<"Create Username: ";
cin>>username;
cout<<"Create Password: ";
cin>>password;
cout<<"Enter Email ID: ";
cin>>email;
string query="insert into userTable(userName,passwords,emailID) values('"+username+"','"+password+"','"+email+"');";
mysql_main::res_set =execute_query(mysql_main::connect_obj,query);
cout<<"Registeration Successfull... :)\nThanks for registering with us..\nNow please login to continue.."<<endl;
}
mysql_close (mysql_main::connect_obj);
return 0;
}