Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <vector>
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <stdio.h>
- #include "functions.h"
- using namespace std;
- int main(){
- initUserCheck(); // Checks to make sure that a user is registered, if not creates a new one.
- Login:
- string usrname;
- string psword;
- string rpsword;
- string path;
- string ext = ".DTBF";
- int adminLevel = 0;
- printf("Username: ");
- cin >> usrname;
- printf("Password: ");
- cin >> psword;
- const char *appdata = std::getenv ( "APPDATA" );
- path = appdata;
- path += "\\myprogram\\files\\users\\" + usrname + ext;
- ifstream readUser(path.c_str());
- readUser >> rpsword;
- if(!readUser){
- if(usrname == "Guest" or "guest"){
- printf("You are a guest. \n");
- goto MainProgram;
- }
- printf("Incorrect Username or Password. \n");
- system("PAUSE");
- printf("\n");
- goto Login;
- }
- if(psword != rpsword){
- printf("Incorrect Username or Password. \n");
- printf("Please press any key, and then retry the login.\n");
- cin.get();
- goto Login;
- }
- if (usrname == "admin" or usrname == "Admin"){
- adminLevel = 1;
- }
- MainProgram:
- //MainCode
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement