Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.56 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. int main()
  4. {
  5.     int reboot;
  6.     while(reboot!=0){
  7.         system("cls");
  8.         /*Banner*/
  9.         printf("\n\n\t\t+---------------------------------------+");
  10.         printf("\n\t\t|\t\t\t\t\t|");
  11.         printf("\n\t\t|\tAdmin login system v1.1\t\t|");
  12.         printf("\n\t\t|\t\t\t\t\t|");
  13.         printf("\n\t\t+---------------------------------------+\n\n");
  14.  
  15.         int select;
  16.         printf("\n\t\t[+] Select->");
  17.         printf("\n\t\t[1] Login as admin");
  18.         printf("\n\t\t[2] Visit as students");
  19.         printf("\n\n\t\tinput number which you want: ");
  20.         scanf("%d",&select);
  21.  
  22.  
  23.  
  24.         if(select == 1){
  25.             char user_name[20];
  26.             char pass_word[20];
  27.  
  28.             printf("\n\t\tUsername: ");
  29.             scanf("%s",&user_name);
  30.  
  31.             char user_exist[20]={'a','d','m','i','n'};
  32.  
  33.             if(strcmp(user_name,user_exist)==0){
  34.                 printf("\t\tPassword: ");
  35.                 scanf("%s",&pass_word);
  36.  
  37.  
  38.                 FILE *user_pass;
  39.                 user_pass=fopen("admin.txt","r");
  40.                 char user_pass_str[20];
  41.                 fgets(user_pass_str,20,user_pass);    /*Make "user_pass" to a string "user_pass_str"*/
  42.                 fclose(user_pass);
  43.  
  44.                 if(strcmp(pass_word,user_pass_str)==0){
  45.                     system("cls");
  46.                     printf("\n\n\t\t+-----------------------------------------------+");
  47.                     printf("\n\t\t|\t\t\t\t\t\t|");
  48.                     printf("\n\t\t|\tWelcome...You are logged in. :) \t|");
  49.                     printf("\n\t\t|\t\t\t\t\t\t|");
  50.                     printf("\n\t\t+-----------------------------------------------+\n\n");
  51.                     /*=======================================================*/
  52.                     /*----------------Admin program start here --------------*/
  53.                     /*=======================================================*/
  54.                     printf("\t\t[1] Change password?");
  55.                     printf("\n\t\t[2] Register new student.");
  56.                     printf("\n\t\t[3] Update student info.");
  57.                     printf("\n\t\t[4] Search student by id.");
  58.  
  59.                     int admin_choice;
  60.                     printf("[+] Chooose: ");
  61.                     scanf("%d",&admin_choice);
  62.                     if(admin_choice==1){
  63.                         FILE *pass_change;
  64.                         pass_change=fopen("admin.txt","w");
  65.                         char pass_change_input[20];
  66.                         printf("Write a new password: ");
  67.                         scanf("%s",&pass_change_input[20]);
  68.                         fwrite(pass_change_input,20,pass_change);
  69.                         fclose(pass_change);
  70.                     }
  71.                     else if(admin_choice==2){}
  72.                     else if(admin_choice==3){}
  73.                     else if(admin_choice==4){}
  74.                     else{}
  75.  
  76.                 }else{
  77.                     printf("\n\n\t\t[-] Password incorrect.\n\n");  /* Password incorrect condition */
  78.                 }
  79.             }else{
  80.                 printf("\n\t\t[-] Username incorrect.\n");  /* Username incorrect condition */
  81.             }
  82.         }
  83.         else if(select == 2){
  84.             /* Students area */
  85.         }else{
  86.         printf("\n\t\tInput [1] or [2] not others number.\n\n"); /* First input condition*/
  87.         }
  88.     printf("\n\n\t\t[0] for stop program [1] for reboot: "); /* This line for reoot this program */
  89.     scanf("%d",&reboot);
  90.     }
  91.     return 0;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement