Advertisement
notjacob

C++ multi user login system (non functional for now)

Nov 30th, 2019
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int
  7. main ()
  8. {
  9.   vector < string > accinfo =
  10.   {
  11.   "admin admin"};
  12.   string hpass = "";
  13.   string hem = "";
  14.   string facc = "";
  15.   string phem = "";
  16.   string phpass = "";
  17.   string len = "";
  18.   int a = 0;
  19.   int b = 0;
  20.   int lloop = 0;
  21.  
  22.   a = 1;
  23.   while (a == 1)
  24.     {
  25.       a = 2;
  26.       cout << "Welcome to the website!\n\n";
  27.       cout << "Would you like to register or login?\n1) register\n2) login\n";
  28.       cin >> b;
  29.  
  30.       if (b == 1)
  31.     {
  32.       cout << "Thank you for regsitering with us!\n\n";
  33.       cout << "Please enter your email:\n";
  34.       cin >> hem;
  35.       cout << "Please enter a password:\n";
  36.       cin >> hpass;
  37.       if (hem != "" && hpass != "")
  38.         {
  39.           cout << "Registration complete!\n\n";
  40.           facc = hem + " " + hpass;
  41.           accinfo.push_back (facc);
  42.           a = 1;
  43.  
  44.         }
  45.       else
  46.         {
  47.           cout << "Invalid entry for: password/email\n";
  48.           a = 1;
  49.         }
  50.  
  51.     }
  52.       else if (b == 2)
  53.     {
  54.       cout << "Login:\n\n";
  55.       cout << "enter email:\n";
  56.       cin >> phem;
  57.       cout << "enter password:\n";
  58.       cin >> phpass;
  59.       len = phem + phpass;
  60.       for (int i = 0; i < accinfo.size (); i++)
  61.         {
  62.  
  63.           if (len == accinfo[i])
  64.         {
  65.           lloop = 1;
  66.           while (lloop == 1)
  67.             {
  68.               lloop = 0;
  69.               cout << "Succesful login!\n";
  70.             }
  71.         }
  72.           else if (i < accinfo.size() && len != accinfo[i])
  73.         {
  74.           lloop = 1;
  75.         }
  76.           else if (i == accinfo.size() && len != accinfo[i])
  77.         {
  78.           cout << "Login failed";
  79.           a == 1;
  80.         }
  81.           else if (i == accinfo.size() && len == accinfo[i])
  82.         {
  83.           cout << "Login Succesful";
  84.         }
  85.  
  86.  
  87.         }
  88.     }
  89.  
  90.     }
  91.  
  92.  
  93.  
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement