Monday, August 27, 2018

Login With Text File in C++

A simple login system that I have created using C++ and Text file I am using Dev C++ in writing this code.

I am currently accepting programming work, it project, school 

programming projects , thesis and capstone projects, IT consulting 

work, computer tutorials and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.
My email address are the following jakerpomperada@gmail.com, jakerpomperada@aol.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

My personal website is http://www.jakerpomperada.com



Sample Program Output



Program Listing

// login.cpp
// Author    : Mr. Jake R. Pomperada, BSCS,MAED-IT
// Date      : August 27, 2018   Monday  10:32 PM
// Location  : Bacolod City, Negros Occidental Philippines.
// Website   : http://www.jakerpomperada.com
// Email     : jakerpomperada@jakerpomperada.com and jakerpomperada@gmail.com

#include <iostream>
#include <fstream>
#include <cstring>
#include <conio.h>
#include <stdlib.h>

using namespace std

int start()
{
char login_password[50];
char stored_password[50];   
char login_username[50];
char stored_username[50];

fstream pull("users.txt",ios::in);
if (!pull) { 
    cout<<"File not loaded!"<<endl;
    return -1; 
}
system("COLOR F0");
cout <<"\n\n";
cout << "\tPassword Security With Text File in C++";
cout <<"\n\n";
cout<<"\tEnter Your Username: ";
cin>>login_username;

while(strcmp(login_username,stored_username)){ 

    pull>>stored_username;
    
    if (pull.eof()){  
    cout <<"\n\n"; 
        cout<<"\tUsername does not exist. "<<"\n";
        cout <<"\n\n";
        system("pause");
        return -1;  
    }
}
pull>>stored_password; 

cout<<"\tEnter Password: "; 
cin>>login_password;

while(strcmp(stored_password,login_password)){
    cout<<"\tWrong password. Please Try again? "<<"\n";
    cout<<"\tEnter Your Password :  ";
    cin>>login_password;
    start();
}
cout <<"\n\n";
cout<<"\tYou Login successfully !!!"<<"\n";
cout <<"\n\n";
cout <<"\tWelcome to the system.";
cout <<"\n\n";
system("pause");
return 0;

}


int main()
{
    start();
}   


the fist part is the username and the second column is the password in the users.txt text file

users.txt

jake pomperada
allie pomperada
jacob pomperada
julianna pomperada
lydia pomperada
admin admin
user password
1234 1234

No comments:

Post a Comment