What's new

C/C++ Simple Console Login System

  • Thread starter XeClutch
  • Start date
  • Views 9,267
XeClutch

XeClutch

Raised on 7S
Mythical Veteran Programmer Modder
Messages
3,690
Reaction score
2,459
Points
690
Sin$
7
I got bored so I made this login / registration system
DO NOT USE THIS FOR ANYTHING, THIS IS A TERRIBLE SYSTEM!!!!!!!!!

Code:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <windows.h>
 
char initChoice;
 
char username;
char password;
char usery0;
char passy0;
 
void Login();
void Register();
 
int main()
{
    system("title XeClutch - Simple Login System");
    system("color a");
    printf("Hello, what would you like to do?\n[A] Login\n[B] Register\n");
    scanf("%c", &initChoice);
    if(initChoice == 'A' || initChoice == 'a')
    {
        Login();
    }
    else if(initChoice == 'B' || initChoice == 'b')
    {
        Register();
    }
    else
    {
        printf("Invalid Operation...");
        system("pause");
    }
    return 0;
}
 
void Login()
{
    printf("\n\nPlease enter your username: ");
    scanf("%s", &usery0);
    if(usery0 == username)
    {
        printf("Please enter your password: ");
        scanf("%s", &password);
        if(passy0 == password)
        {
            printf("Successful Login!");
            system("pause");
        }
        else
        {
            printf("Incorrect Password...\n");
            system("pause");
        }
    }
    else
    {
        printf("Incorrect Username...\n");
        system("pause");
    }
}
 
void Register()
{
    printf("\n\nEnter a new username: ");
    scanf("%s", &username);
    printf("Enter a new password: ");
    scanf("%s", &password);
    printf("\nRegistration Successful!\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
    main();
}
 
KaitenThaHax

KaitenThaHax

Enthusiast
Messages
297
Reaction score
75
Points
85
Sin$
0
could use mysql but can be easily decrypted if you know what your doing
 
Call me LEWY

Call me LEWY

Maybe?
Forum Addict Grammar Nazi Mr. Nice Guy
Messages
3,961
Reaction score
597
Points
515
Sin$
7
Where is username & password stored? it looks like you're comparing usery0 and passy0 to nothing.
 
XeClutch

XeClutch

Raised on 7S
Mythical Veteran Programmer Modder
Messages
3,690
Reaction score
2,459
Points
690
Sin$
7
Where is username & password stored? it looks like you're comparing usery0 and passy0 to nothing.

usery0 is the login side of it, I just used it basically as a null, I dont really know how to explain it :tongue:
 
Call me LEWY

Call me LEWY

Maybe?
Forum Addict Grammar Nazi Mr. Nice Guy
Messages
3,961
Reaction score
597
Points
515
Sin$
7
usery0 is the login side of it, I just used it basically as a null, I dont really know how to explain it :tongue:

A user inputs their username and password into usery0 and passy0, and then those two variables are compared to username and password. I see username and password does not equal to anything. Did you leave that blank for people to set a username or password?

I'm not having a go at your code btw, hope I'm not coming across as an ***hole.

Ah, I didn't see the register part of your code.
 
XeClutch

XeClutch

Raised on 7S
Mythical Veteran Programmer Modder
Messages
3,690
Reaction score
2,459
Points
690
Sin$
7
A user inputs their username and password into usery0 and passy0, and then those two variables are compared to username and password. I see username and password does not equal to anything. Did you leave that blank for people to set a username or password?

I'm not having a go at your code btw, hope I'm not coming across as an ***hole.

Ah, I didn't see the register part of your code.

yeah, if you look into the register void you will see why I did it, I used usery0 and passy0 to compare the string entered when you login and the stored username and password strings.
 
Top Bottom
Login
Register