Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main()
- {
- int reboot;
- while(reboot!=0){
- system("cls");
- /*Banner*/
- printf("\n\n\t\t+---------------------------------------+");
- printf("\n\t\t|\t\t\t\t\t|");
- printf("\n\t\t|\tAdmin login system v1.1\t\t|");
- printf("\n\t\t|\t\t\t\t\t|");
- printf("\n\t\t+---------------------------------------+\n\n");
- int select;
- printf("\n\t\t[+] Select->");
- printf("\n\t\t[1] Login as admin");
- printf("\n\t\t[2] Visit as students");
- printf("\n\n\t\tinput number which you want: ");
- scanf("%d",&select);
- if(select == 1){
- char user_name[20];
- char pass_word[20];
- printf("\n\t\tUsername: ");
- scanf("%s",&user_name);
- char user_exist[20]={'a','d','m','i','n'};
- if(strcmp(user_name,user_exist)==0){
- printf("\t\tPassword: ");
- scanf("%s",&pass_word);
- FILE *user_pass;
- user_pass=fopen("admin.txt","r");
- char user_pass_str[20];
- fgets(user_pass_str,20,user_pass); /*Make "user_pass" to a string "user_pass_str"*/
- fclose(user_pass);
- if(strcmp(pass_word,user_pass_str)==0){
- system("cls");
- printf("\n\n\t\t+-----------------------------------------------+");
- printf("\n\t\t|\t\t\t\t\t\t|");
- printf("\n\t\t|\tWelcome...You are logged in. :) \t|");
- printf("\n\t\t|\t\t\t\t\t\t|");
- printf("\n\t\t+-----------------------------------------------+\n\n");
- /*=======================================================*/
- /*----------------Admin program start here --------------*/
- /*=======================================================*/
- printf("\t\t[1] Change password?");
- printf("\n\t\t[2] Register new student.");
- printf("\n\t\t[3] Update student info.");
- printf("\n\t\t[4] Search student by id.");
- int admin_choice;
- printf("[+] Chooose: ");
- scanf("%d",&admin_choice);
- if(admin_choice==1){
- FILE *pass_change;
- pass_change=fopen("admin.txt","w");
- char pass_change_input[20];
- printf("Write a new password: ");
- scanf("%s",&pass_change_input[20]);
- fwrite(pass_change_input,20,pass_change);
- fclose(pass_change);
- }
- else if(admin_choice==2){}
- else if(admin_choice==3){}
- else if(admin_choice==4){}
- else{}
- }else{
- printf("\n\n\t\t[-] Password incorrect.\n\n"); /* Password incorrect condition */
- }
- }else{
- printf("\n\t\t[-] Username incorrect.\n"); /* Username incorrect condition */
- }
- }
- else if(select == 2){
- /* Students area */
- }else{
- printf("\n\t\tInput [1] or [2] not others number.\n\n"); /* First input condition*/
- }
- printf("\n\n\t\t[0] for stop program [1] for reboot: "); /* This line for reoot this program */
- scanf("%d",&reboot);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement