-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject.cpp
More file actions
208 lines (186 loc) · 6.63 KB
/
project.cpp
File metadata and controls
208 lines (186 loc) · 6.63 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#include<iostream>
#include<istream>
#include<fstream>
#include<stdlib.h>
#include<string.h>
using namespace std;
void login();
void registr();
void forgot();
main()
{
int choice;
cout<<"***********************************************************************\n\n\n";
cout<<" Welcome to login page \n\n";
cout<<"******************* MENU *******************************\n\n";
cout<<"1.LOGIN"<<endl;
cout<<"2.REGISTER"<<endl;
cout<<"3.FORGOT PASSWORD (or) USERNAME"<<endl;
cout<<"4.Exit"<<endl;
cout<<"\nEnter your choice :";
cin>>choice;
cout<<endl;
switch(choice)
{
case 1:
login();
break;
case 2:
registr();
break;
case 3:
forgot();
break;
case 4:
cout<<"Thank you\n";
break;
default:
system("cls");
cout<<"You've made a mistake , give it a try again\n"<<endl;
main();
}
}
void registr()
{
int count;
string firstname,lastname,city,user,pass,u,p;
system("cls");
cout<<"please enter the following details"<<endl;
cout << "Firstname: ";
cin >> firstname;
cout << "Lastname: ";
cin >> lastname;
cout << "City: ";
cin >> city;
cout<<"USERNAME: ";
cin>>user;
cout<<"PASSWORD :";
cin>>pass;
ifstream input("database.txt");
while(input>>u>>p)
{
if(u==user && p==pass)
{
count=1;
system("cls");
}
}
if(count==1)
{
cout<<"\nHello "<<user<<"\n REGISTERATION SUCCESSFULL\nWe're glad that you're here.\nThanks for getting registered with us!\n";
cout<<"Your account details are:\n Username: "<<user<<"\n Password: "<<pass;
cin.get();
cin.get();
main();
}
else
{
cout<<"\nLOGIN ERROR\nPlease check your username and password\n";
main();
}
input.close();
}
void login()
{
string reguser,regpass,ru,rp;
system("cls");
cout<<"Enter the username :";
cin>>reguser;
cout<<"\nEnter the password :";
cin>>regpass;
ofstream reg("database.txt",ios::app);
reg<<reguser<<' '<<regpass<<endl;
system("cls");
cout<<"\nRegistration Sucessful\n";
main();
}
void forgot()
{
int ch;
system("cls");
cout<<"Forgotten ? We're here for help\n";
cout<<"1.Search your id by username"<<endl;
cout<<"2.Search your id by password"<<endl;
cout<<"3.Main menu"<<endl;
cout<<"Enter your choice :";
cin>>ch;
switch(ch)
{
case 1:
{
int count=0;
string searchuser,su,sp;
cout<<"\nEnter your remembered username :";
cin>>searchuser;
ifstream searchu("database.txt");
while(searchu>>su>>sp)
{
if(su==searchuser)
{
count=1;
}
}
searchu.close();
if(count==1)
{
cout<<"\n\nSuccess!, Account found!!!\n";
cout<<"\nYour password is "<<sp;
cin.get();
cin.get();
system("cls");
main();
}
else
{
cout<<"\nSorry, Your userID is not found in our database\n";
cout<<"\nPlease kindly contact your system administrator for more details \n";
cin.get();
cin.get();
main();
}
break;
}
case 2:
{
int count=0;
string searchpass,su2,sp2;
cout<<"\nEnter the remembered password :";
cin>>searchpass;
ifstream searchp("database.txt");
while(searchp>>su2>>sp2)
{
if(sp2==searchpass)
{
count=1;
}
}
searchp.close();
if(count==1)
{
cout<<"\nYour password is found in the database \n";
cout<<"\nYour Id is : "<<su2;
cin.get();
cin.get();
system("cls");
main();
}
else
{
cout<<"Sorry, We cannot found your password in our database \n";
cout<<"\nkindly contact your administrator for more information\n";
cin.get();
cin.get();
main();
}
break;
}
case 3:
{
cin.get();
main();
}
default:
cout<<"Sorry, You entered wrong choice. Kindly try again"<<endl;
forgot();
}
}