Advertisement
reyzaku1

Code

Jul 10th, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <fstream>
  3. #include <iostream>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. bool IsLoggedIn() {
  9.  
  10. string username, password, pw, um;
  11.  
  12. cout << "Enter Username : "; cin >> username;
  13. cout << "Enter Password : "; cin >> password;
  14.  
  15. ifstream read("F:\\" + username + ".txt");
  16. getline(read, um);
  17. getline(read, pw);
  18.  
  19. if (um == username && pw == password) {
  20.  
  21. return true;
  22. }
  23. else {
  24.  
  25. return false;
  26. }
  27. }
  28.  
  29. void setUsername() {
  30.  
  31. }
  32.  
  33. void setPassword() {
  34.  
  35. }
  36.  
  37. int main() {
  38.  
  39. int pil;
  40.  
  41. cout << "--- Main Menu ---" << endl;
  42. cout << "[1] Register " << endl;
  43. cout << "[2] Login " << endl;
  44. cout << "[3] Admin Site";
  45. cout << "" << endl;
  46. cout << "Input your Chouse (1-3) : " << endl;
  47. cin >> pil;
  48.  
  49. if (pil == 1) {
  50.  
  51. string password, username;
  52.  
  53. cout << "Input Your username : " << endl; cin >> username;
  54. if (username.length() > 16 || username.length() < 5) {
  55. cout << "Your username must be 5-16 character!" << endl;
  56. main();
  57. }
  58. cout << "Input your Password : " << endl; cin >> password;
  59. if (password.length() > 16 || password.length() < 4) {
  60. cout << "Your password must be 4-16 character!" << endl;
  61. main();
  62. }
  63.  
  64. ofstream file;
  65. file.open("F:\\" + username + ".txt");
  66.  
  67. file << username << endl << password;
  68.  
  69. file.close();
  70.  
  71. main();
  72. }
  73.  
  74. else if (pil == 2) {
  75.  
  76. bool status = IsLoggedIn();
  77.  
  78. if (!status) {
  79. cout << "False Login!" << endl;
  80. system("PAUSE");
  81. return 0;
  82. }
  83. else {
  84. cout << "Succesfully Logged In!" << endl;
  85. return 1;
  86. main();
  87. }
  88. }
  89. else if (pil == 3) {
  90.  
  91. bool status = IsLoggedIn();
  92.  
  93. if (status == true) {
  94. cout << "[]-- WELCOME TO ADMIN SITE --[]" << endl;
  95. cout << "" << endl;
  96. cout << "Still Development, Comeback Later!" << endl;
  97. cout << "Press Esc. to back to main menu!" << endl;
  98. }
  99. else {
  100. cout << "- Access Denied! Unsificient permision!" << endl;
  101.  
  102. main();
  103. }
  104.  
  105. }
  106. main();
  107.  
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement