notjacob

C++ 1 user login system

Nov 28th, 2019
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.82 KB | None | 0 0
  1. /***************************************
  2.  SINGLE USER LOGIN SYSTEM
  3.  By Jacob Blair
  4.  ***************************************/
  5.  
  6. #include <iostream>
  7.  
  8. using namespace std;
  9.  
  10. int
  11. main ()
  12. {
  13.   string mypass = "";
  14.   string myemail = "";
  15.   string epass = "";
  16.   string email = "";
  17.   bool reg = false;
  18.   int ch = 0;
  19.   int hom = 0;
  20.   hom = 1;
  21.   while (hom == 1)
  22.     {
  23.       hom = 0;
  24.       cout << "Would you like to login or register? (1/2)\n";
  25.       cin >> ch;
  26.       if (ch == 2 && mypass == "" && myemail == "")
  27.     {
  28.       cout << "Thank you for registering with us!\n\n";
  29.       cout << "Please enter your email\n";
  30.       cin >> myemail;
  31.       cout << "Email registered\nPlease enter a password\n";
  32.       cin >> mypass;
  33.       cout << "Successfully registered!\n";
  34.       hom = 1;
  35.  
  36.     }
  37.       else if (ch == 2 && mypass != "")
  38.     {
  39.       cout << "Already registered!\n";
  40.       hom = 1;
  41.     }
  42.       else if (ch == 2 && myemail != "")
  43.     {
  44.       cout << "Already registered!\n";
  45.       hom = 1;
  46.     }
  47.       else if (ch == 1 && mypass != "" && myemail != "")
  48.     {
  49.       cout << "Enter password\n";
  50.       cin >> epass;
  51.       if (epass != mypass)
  52.         {
  53.           cout << "Invalid password\n";
  54.           hom = 1;
  55.         }
  56.       else
  57.         {
  58.           cout << "Enter email\n";
  59.           cin >> email;
  60.           if (email != myemail)
  61.         {
  62.           cout << "Invalid email\n";
  63.           hom = 1;
  64.         }
  65.           else
  66.         {
  67.           if (epass == mypass && email == myemail)
  68.             {
  69.               cout << " Successfully logged in ! ";
  70.  
  71.             }
  72.           else
  73.             {
  74.               cout << " Incorrect login.";
  75.             }
  76.         }
  77.         }
  78.     }
  79.       else if (ch == 1 && mypass == " ")
  80.     {
  81.       cout << " Not registered ! \n ";
  82.       hom = 1;
  83.     }
  84.  
  85.       else if (ch == 1 && myemail == " ")
  86.     {
  87.       cout << " Not registered ! \n ";
  88.       hom = 1;
  89.  
  90.     }
  91.     else {
  92.         cout << " Invalid option. \n ";
  93.         hom = 1;
  94.     }
  95.     }
  96.  
  97. }
Advertisement
Add Comment
Please, Sign In to add comment