-
Notifications
You must be signed in to change notification settings - Fork 0
/
Database.cpp
128 lines (118 loc) · 4.23 KB
/
Database.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include <iostream>
#include <Windows.h>
#include <vector>
#include <string>
#include <conio.h>
struct users
{
std::string username;
std::string password;
bool isfull = 0;
};
int main()
{
std::vector<int> id[1];
int userquantity = 1;
bool press = 0;
std::string usernamelogin, passwordlogin;
users user[100];
bool usernamehasset = 0;
while (press == 0)
{
system("cls");
std::cout << "Press 1 to Log in | Press 2 to Sign in\n";
if ((GetKeyState('1') & 0x8000))
{
Sleep(100);
system("cls");
std::cout << "|Introduce your username|\n";
std::cin >> usernamelogin;
system("cls");
std::cout << "|Introduce your password|\n";
std::cin >> passwordlogin;
system("cls");
for (int i = 1; i < 100; i++)
{
if (usernamelogin.compare(user[i].username) == 0)
{
if (passwordlogin.compare(user[i].password) == 0)
{
std::cout << "You have souccessfully logged in";
Sleep(1000);
system("cls");
i = 100;
}
else
{
std::cout << "The username/password is incorrect";
Sleep(1000);
i = 100;
}
}
}
}
if ((GetKeyState('2') & 0x8000))
{
for (int i = 1; i < 100; i++)
{
if (user[i].isfull == 0)
{
system("cls");
if (usernamehasset == 0)
{
std::cout << "|Itroduce your username|\n";
std::cin >> user[i].username;
for (int j = 0; j < i; j++)
{
if (user[j].username.compare(user[i].username) == 0)
{
system("cls");
std::cout << "This username is already taken\n";
Sleep(1000);
j = 100;
i = 0;
}
else if (user[i].username.length() < 3)
{
system("cls");
std::cout << "The username is too short\n";
Sleep(1000);
j = 100;
i = 0;
}
else if (j == i - 1)
{
j = 100;
usernamehasset = 1;
}
}
}
if (usernamehasset == 1)
{
system("cls");
std::cout << "|Introduce your password|\n";
std::cin >> user[i].password;
for (int j = 0; j < i; j++)
{
if (user[i].password.length() < 3)
{
std::cout << "This password is too short\n";
j = 0;
i = 0;
}
else
{
std::cout << "|You have successfully signed in|\n Username: " << user[i].username << std::endl << "Password: " << user[i].password << std::endl;
user[i].isfull = 1;
j = 100;
i = 100;
usernamehasset = 0;
Sleep(3000);
}
}
}
}
}
}
}
}