Answers for "C++ login system"

C++
1

login system with c++

//Written by itsKrish01
//If you find any error or mistake in this code, then please contact me.

#include <iostream>


using namespace std;

int main() {

  string login;
  string user;
  int login_times;
  string password_login;
  string password;
  
  string command;

  cout << "exit/login/register"<<endl<<"Command: ";
  cin >> command;

  while(command != "exit"){

    if(command == "register"){
      cout << "nn"<<endl;
      cout << "Registeration"<<endl<<"----------------"<<endl;
      cout <<"regsiter: ";
      cin >> user;
      cout <<"password: ";
      cin >> password; 

      cout << "nn";
      cout << "Registered Successfully!"<<endl;
      cout << "nn";
      cout << "exit/login/register"<<endl<<"Command: ";


      cin >> command;

      login_times = 3;
      while(login_times > 0){
        

        cout << "nn";
        cout << "Login"<<endl<<"_____";
        cout << "n";

        cout << "login: ";
        cin >> login;
        cout << "Password: ";
        cin >> password_login;

        

        

        if(login == user && password_login == password){
          cout << "loged in Successfully!"<<endl;
          cout << "Welcome"<<user<<"!";
          
          break;

        }
        else if(login != user && password_login == password){

          cout << "username is incorrect!"<<endl;
          login_times--;
          
        }

        else if(login == user && password_login != password){

          cout << "password is incorrect!"<<endl;
          login_times--;
          
        }
        else{
          cout << "Everything is incorrect!"<<endl;
          login_times--;
        }

        

        


      }
      cout << "you have entered wrong details for more than 3 times, So we have blocked your account!";
      break;
    }

  }

}
Posted by: Guest on October-26-2021
0

how to make a login c++

// a simple login for c++ using while loops and io (input output)
#include <iostream>
#include <string>

using namespace std;

int main() {
  cout << "please enter password";
  string pass = "0";                  // making a string for user input
  cin >> pass;                        // could be replaced with getline(cin, pass);
  while (pass = "1234") {             // while loop for when password is wrong
    cout << "incorrect, try again";
    cin >> pass;                      // could be replaced with getline(cin, pass);
  }
  cout << "correct password";         // runs when the while loop is no longer happening
}
Posted by: Guest on September-28-2020

Browse Popular Code Answers by Language