Login Prompt Question !!! How to set specific usernames C++

Discussion in 'Programming General' started by Goomba, Nov 23, 2009.

Login Prompt Question !!! How to set specific usernames C++
  1. Unread #1 - Nov 23, 2009 at 1:18 AM
  2. Goomba
    Joined:
    Nov 21, 2009
    Posts:
    100
    Referrals:
    0
    Sythe Gold:
    0

    Goomba Active Member

    Login Prompt Question !!! How to set specific usernames C++

    Hey Ive Got A Login Prompt Here That Ive Gotton From A Thread On Here And Id Like To Know How To Set Specific Usernames On It, Like So If I Wanted

    Username:Bob
    Password:1234

    How Would I Do This??? Here Is The Code Im Using For Login Prompt


    Code:
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    const string uc = "Username";
    const string pc = "Password";
    
    string username,password;
    int id;
    bool result broncos12;
    
    bool login(string u,string p) {
         if(u == uc && p == pc) return(true);
         if(u != uc || p != pc) return(false);
    }
    
    int setid(string u) {
         if(u == uc) return(1);
    }
    
    int main(int argc, char *argv[])
    {
          cout << "Username: ";
          cin >> username;
          cout << "Password: ";
          cin >> password;
          result = login(username,password);
          if(result == true) id = setid(username);
          cout << "Welcome " << username << ", you have been logged in and your ID is " << id;
     
  3. Unread #2 - Nov 23, 2009 at 11:48 AM
  4. super_
    Joined:
    Dec 20, 2008
    Posts:
    91
    Referrals:
    0
    Sythe Gold:
    0

    super_ Member

    Login Prompt Question !!! How to set specific usernames C++

    check other thread for issues with that system
     
  5. Unread #3 - Nov 23, 2009 at 12:40 PM
  6. Govind
    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Login Prompt Question !!! How to set specific usernames C++

    You NEED to store them somewhere, like a file, or a registry key. If you want it to be secure at all, the passwords have to be irreversibly encrypted too.
     
  7. Unread #4 - Nov 23, 2009 at 4:41 PM
  8. Goomba
    Joined:
    Nov 21, 2009
    Posts:
    100
    Referrals:
    0
    Sythe Gold:
    0

    Goomba Active Member

    Login Prompt Question !!! How to set specific usernames C++

    Im new to c++ so what do i need to store?? I understand my passwords and username need to be stored somewhere now, but i dont know how i store them can someone give me the code for

    Username Bob
    Password 1234

    Please. Im not to worried aboiut encrytion yet but i know how that works thx iin advanced
     
  9. Unread #5 - Nov 28, 2009 at 4:52 PM
  10. iDEEKAY
    Joined:
    Aug 25, 2009
    Posts:
    6
    Referrals:
    0
    Sythe Gold:
    0

    iDEEKAY Newcomer

    Login Prompt Question !!! How to set specific usernames C++

    Learn C++, then after you've learn the basics of C/C++ you can understand my words.

    Either you can save them on MySQL(Secure) or you can do it in registry.

    I suggest you use MySQL since it's very portable and secure.
     
  11. Unread #6 - Nov 29, 2009 at 2:46 PM
  12. blindkilla
    Joined:
    Jun 22, 2005
    Posts:
    1,896
    Referrals:
    0
    Sythe Gold:
    6
    Discord Unique ID:
    282000633404456960
    Discord Username:
    sogord

    blindkilla Guru
    $25 USD Donor New

    Login Prompt Question !!! How to set specific usernames C++

    I don't think this is a serious project for him, rather that he is just trying to learn how to use c++. Yes, if you were making an actual login system this would not be secure, but for learning purposes this is fine.
     
  13. Unread #7 - Nov 30, 2009 at 6:30 AM
  14. Goomba
    Joined:
    Nov 21, 2009
    Posts:
    100
    Referrals:
    0
    Sythe Gold:
    0

    Goomba Active Member

    Login Prompt Question !!! How to set specific usernames C++

    Yess your right :) but i would really like it to be so i can set usernames, like so if its wrong it says invalid
     
  15. Unread #8 - Nov 30, 2009 at 9:36 AM
  16. blindkilla
    Joined:
    Jun 22, 2005
    Posts:
    1,896
    Referrals:
    0
    Sythe Gold:
    6
    Discord Unique ID:
    282000633404456960
    Discord Username:
    sogord

    blindkilla Guru
    $25 USD Donor New

    Login Prompt Question !!! How to set specific usernames C++

    Try something like that, I only changed the if/else statement at the bottom a bit.


    Code:
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    const string uc = "Username";
    const string pc = "Password";
    
    string username,password;
    int id;
    bool result broncos12;
    
    bool login(string u,string p) {
         if(u == uc && p == pc) return(true);
         if(u != uc || p != pc) return(false);
    }
    
    int setid(string u) {
         if(u == uc) return(1);
    }
    
    int main(int argc, char *argv[])
    {
          cout << "Username: ";
          cin >> username;
          cout << "Password: ";
          cin >> password;
          result = login(username,password);
          if(result == true) 
         {
            id = setid(username);
            cout << "Welcome " << username << ", you have been logged in and your ID is " << id;
         }
           else
          {
             cout << "You entered an invalid username or password";
          }
     
  17. Unread #9 - Nov 30, 2009 at 6:43 PM
  18. Goomba
    Joined:
    Nov 21, 2009
    Posts:
    100
    Referrals:
    0
    Sythe Gold:
    0

    Goomba Active Member

    Login Prompt Question !!! How to set specific usernames C++


    This Is Giving Me Errors With The Bottom } So i dont know what to do ?
     
  19. Unread #10 - Jan 13, 2010 at 12:43 PM
  20. Eduard
    Joined:
    May 26, 2006
    Posts:
    45
    Referrals:
    1
    Sythe Gold:
    0

    Eduard Member
    Banned

    Login Prompt Question !!! How to set specific usernames C++

    i'll make something easyer and better to use for you. ok? a sec.
     
  21. Unread #11 - Jan 13, 2010 at 12:54 PM
  22. Eduard
    Joined:
    May 26, 2006
    Posts:
    45
    Referrals:
    1
    Sythe Gold:
    0

    Eduard Member
    Banned

    Login Prompt Question !!! How to set specific usernames C++

    Code:
    #include <stdio.h>
    
    int main()
    {
        char username[100] = "username";
        char password[100] = "password";
        char passbuffer[100] = "";
        char userbuffer[100] = "";
    
        printf("Please type your username: ");
        scanf("%s",&userbuffer);
        printf("Please type you password: ");
        scanf("%s",&passbuffer);
    
        if (strcmp(userbuffer,username) == 0)
        {
            if (strcmp(passbuffer,password) == 0)
            {
                printf("Logged in succesfull !");
            }
        }
            else
            {
                printf("Sorry invalid password! ");
                return -1;
            }
        return 0;
    }
    
     
  23. Unread #12 - Jan 29, 2010 at 9:29 PM
  24. war833
    Joined:
    Dec 11, 2008
    Posts:
    82
    Referrals:
    0
    Sythe Gold:
    0

    war833 Member

    Login Prompt Question !!! How to set specific usernames C++

    Store them in the registry?

    ROFLMAO
     
< Reflection Help (I am smart) | Couple of questions >

Users viewing this thread
1 guest


 
 
Adblock breaks this site