Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <fstream>
- #include <iostream>
- #include <string>
- using namespace std;
- bool IsLoggedIn() {
- string username, password, pw, um;
- cout << "Enter Username : "; cin >> username;
- cout << "Enter Password : "; cin >> password;
- ifstream read("F:\\" + username + ".txt");
- getline(read, um);
- getline(read, pw);
- if (um == username && pw == password) {
- return true;
- }
- else {
- return false;
- }
- }
- void setUsername() {
- }
- void setPassword() {
- }
- int main() {
- int pil;
- cout << "--- Main Menu ---" << endl;
- cout << "[1] Register " << endl;
- cout << "[2] Login " << endl;
- cout << "[3] Admin Site";
- cout << "" << endl;
- cout << "Input your Chouse (1-3) : " << endl;
- cin >> pil;
- if (pil == 1) {
- string password, username;
- cout << "Input Your username : " << endl; cin >> username;
- if (username.length() > 16 || username.length() < 5) {
- cout << "Your username must be 5-16 character!" << endl;
- main();
- }
- cout << "Input your Password : " << endl; cin >> password;
- if (password.length() > 16 || password.length() < 4) {
- cout << "Your password must be 4-16 character!" << endl;
- main();
- }
- ofstream file;
- file.open("F:\\" + username + ".txt");
- file << username << endl << password;
- file.close();
- main();
- }
- else if (pil == 2) {
- bool status = IsLoggedIn();
- if (!status) {
- cout << "False Login!" << endl;
- system("PAUSE");
- return 0;
- }
- else {
- cout << "Succesfully Logged In!" << endl;
- return 1;
- main();
- }
- }
- else if (pil == 3) {
- bool status = IsLoggedIn();
- if (status == true) {
- cout << "[]-- WELCOME TO ADMIN SITE --[]" << endl;
- cout << "" << endl;
- cout << "Still Development, Comeback Later!" << endl;
- cout << "Press Esc. to back to main menu!" << endl;
- }
- else {
- cout << "- Access Denied! Unsificient permision!" << endl;
- main();
- }
- }
- main();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement