Adblock breaks this site

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

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

  1. Goomba

    Goomba Active Member

    Joined:
    Nov 21, 2009
    Posts:
    100
    Referrals:
    0
    Sythe Gold:
    0
    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;
     
  2. super_

    super_ Member

    Joined:
    Dec 20, 2008
    Posts:
    91
    Referrals:
    0
    Sythe Gold:
    0
    Login Prompt Question !!! How to set specific usernames C++

    check other thread for issues with that system
     
  3. Govind

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    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
    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.
     
  4. Goomba

    Goomba Active Member

    Joined:
    Nov 21, 2009
    Posts:
    100
    Referrals:
    0
    Sythe Gold:
    0
    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
     
  5. iDEEKAY

    iDEEKAY Newcomer

    Joined:
    Aug 25, 2009
    Posts:
    6
    Referrals:
    0
    Sythe Gold:
    0
    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.
     
  6. blindkilla

    blindkilla Guru
    $25 USD Donor New

    Joined:
    Jun 22, 2005
    Posts:
    1,896
    Referrals:
    0
    Sythe Gold:
    6
    Discord Unique ID:
    282000633404456960
    Discord Username:
    sogord
    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.
     
  7. Goomba

    Goomba Active Member

    Joined:
    Nov 21, 2009
    Posts:
    100
    Referrals:
    0
    Sythe Gold:
    0
    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
     
  8. blindkilla

    blindkilla Guru
    $25 USD Donor New

    Joined:
    Jun 22, 2005
    Posts:
    1,896
    Referrals:
    0
    Sythe Gold:
    6
    Discord Unique ID:
    282000633404456960
    Discord Username:
    sogord
    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";
          }
     
  9. Goomba

    Goomba Active Member

    Joined:
    Nov 21, 2009
    Posts:
    100
    Referrals:
    0
    Sythe Gold:
    0
    Login Prompt Question !!! How to set specific usernames C++


    This Is Giving Me Errors With The Bottom } So i dont know what to do ?
     
  10. Eduard

    Eduard Member
    Banned

    Joined:
    May 26, 2006
    Posts:
    45
    Referrals:
    1
    Sythe Gold:
    0
    Login Prompt Question !!! How to set specific usernames C++

    i'll make something easyer and better to use for you. ok? a sec.
     
  11. Eduard

    Eduard Member
    Banned

    Joined:
    May 26, 2006
    Posts:
    45
    Referrals:
    1
    Sythe Gold:
    0
    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;
    }
    
     
  12. war833

    war833 Member

    Joined:
    Dec 11, 2008
    Posts:
    82
    Referrals:
    0
    Sythe Gold:
    0
    Login Prompt Question !!! How to set specific usernames C++

    Store them in the registry?

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


 
 
Adblock breaks this site