Skip to main content

Sign In and Sign Up with C++ (Back-End)

Sign up to the awesomeness of this cool project and get yourself started!


Let's begin!

The code is for initial developing a program through which we can get user register. After registration the user can add the additional details.

As usual a regular user can see it's own information and can update them!

It's basic and many other cool stuffs can be added in it!

So, sit back and relax and let your creativity take over and create something amazing!

Happy Programming!

#include <iostream>
#include <map>
#include <string>
using std::map;
using std::string;
using std::cin;
using std::cout;
class UserDetails
{
string firstName;
string lastName;
string country;
int age;
int pincode;
int mobile;
public:
void get_data()
{
cout<<"\n\tForm\n";
cout<<"\nFirst Name: ";
cin>>firstName;
cout<<"\nLast Name: ";
cin>>lastName;
cout<<"\nAge: ";
cin>>age;
cout<<"\nCountry: ";
cin>>country;
cout<<"\nPin Code: ";
cin>>pincode;
cout<<"\nMobile: ";
cin>>mobile;
return;
}
void show_data()
{
cout<<"\n\tUser Details\n";
cout<<"\nFirst Name: \t";
cout<<firstName;
cout<<"\nLast Name: \t";
cout<<lastName;
cout<<"\nAge: \t";
cout<<age;
cout<<"\nCountry: \t";
cout<<country;
cout<<"\nPin Code: \t";
cout<<pincode;
cout<<"\nMobile: \t";
cout<<mobile;
return;
}
void update_data()
{
std::cout<<"\nTODO";
}
};
class Registration
{
string username;
string password;
public:
map<string, string> database;
Registration()
{
// Default User
database["abc"] = "123";
}
void sign_up()
{
std::cout<<"\nWe welcome you to our organization!\n";
std::cout<<"\tRegistration Form\n";
cout<<"\nUsername:\t";
cin>>username;
cout<<"\nPassword:\t";
cin>>password;
database.insert({username, password});
std::cout<<"\nSuceesfully Registered!\n";
}
};
class Login : public Registration
{
string input_username;
string input_password;
public:
bool sign_in()
{
cout<<"\n\tSign In Page\n";
cout<<"\nUsername:\t";
cin>>input_username;
cout<<"\nPassword:\t";
cin>>input_password;
for(auto key = database.begin(); key != database.end(); key++)
{
if (input_username == key->first)
{
if (input_password == key->second)
{
std::cout<<"\nSuccess: Logged in!\n";
return true;
}
else
{
std::cout<<"\nError: Wrong Password!\n";
}
}
}
std::cout<<"\nError: Username Not Found\n";
return false;
}
};
class Features
{
public:
void user_data()
{
UserDetails data;
int input;
do
{
cout<<"\nUse 1: Edit Profile\n";
cout<<"\nUse 2: See Profile\n";
cout<<"\nUse 0: To Log Out\n";
cin>>input;
switch (input)
{
case 0:
std::cout<<"Bye!";
break;
case 1:
data.get_data();
break;
case 2:
data.show_data();
break;
default:
cout<<"\nError: Invalid Input";
break;
}
}while (input != 0);
return;
}
};
int main()
{
Login server;
Features feat;
int input;
do
{
cout<<"\nUse 1: Sign Up\n";
cout<<"\nUse 2: Sign In\n";
cout<<"\nUse 0: To Exit\n";
cin>>input;
switch (input)
{
case 0:
std::cout<<"Bye!";
break;
case 1:
server.sign_up();
break;
case 2:
if (server.sign_in() == true)
{
feat.user_data();
}
break;
default:
cout<<"\nError: Invalid Input";
break;
}
}
while (input != 0);
return 0;
}

Comments

Popular posts from this blog

Beginners Guide to Code

Coding  750+ hours and that's my advice! Which language? There's a lot of languages available you name it! Choosing the right language is a must because it will be responsible for your coding style, approach for problems solving and it's application. My first coding language was C++, if you see my code most of them follow's it style, my second language was Python, most of the approach for my problem solving follows it. Later on I started learning Kotlin and Dart and they both follow the same style as above! I will recommend you C++ if you are really into programming after that you will be experienced enough to choose any other language. Single or multiple language? Single language won't make you a good developer and that's a fact! Every language has it's unique style but why to limit yourself only to that? Programmer is analyzed by it's approach to solve a problem. Why Iron Man uses multiple armors? Because every armors has it's unique specialty. Sam...

Programming Languages

As a rookie in the vast field of computer science it's the most frequently asked question, "Which programming language should I begin with?" I'm sharing my experience of last 7 years...

Building a Binary Calculator With Object Oriented Programming in C++

Let's begin! Creating a basic calculator is a no biggie! So we are applying the concept of object oriented programming and making this program work until the user ask to end the task, in this calculator we can also intake the value as much as we want without restarting the program! It's one of basis and yet a core project where majority of your programming skills are used! Happy Programming!