• Log in or sign up for an account here: https://www.sythe.org/login

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

Goomba

Active Member
Joined
Nov 21, 2009
Sythe Gold
0
Messages
100
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;
 
Le Monkey
PHP Shit Show 2k26
Potamus
Prove it!
Sythe Awards 2011 Winner
Tier 1 Prizebox
Tortoise Penis
Trole
UWotM8?
Wait, do you not have an Archer rank?
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.
 
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.

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

Yess your right :) but i would really like it to be so i can set usernames, like so if its wrong it says invalid
 
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";
      }
 
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";
      }


This Is Giving Me Errors With The Bottom } So i dont know what to do ?
 
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;
}
 
Runescape Gamblingrunescape gambling
Back
Top