mirror of
https://github.com/yv1ing/Student-Information-Management-System.git
synced 2025-09-16 14:44:46 +08:00
finished work
This commit is contained in:
102
function_module/login_module.c
Normal file
102
function_module/login_module.c
Normal file
@@ -0,0 +1,102 @@
|
||||
#include "stdio.h"
|
||||
#include "string.h"
|
||||
#include "windows.h"
|
||||
#include "stdlib.h"
|
||||
#include "../heads/for_function_module.h"
|
||||
#include "../heads/users.h"
|
||||
#include "../heads/secondary_menu.h"
|
||||
#include "../heads/registered_module.h"
|
||||
|
||||
void login_module(){
|
||||
//<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>
|
||||
system("cls");
|
||||
fflush(stdin);
|
||||
printf("------------------------------ѧ<><D1A7><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ϵͳ------------------------------\n\n");
|
||||
printf("-> <20><>ǰλ<C7B0>ã<EFBFBD><C3A3><EFBFBD>¼\n\n");
|
||||
printf("-> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˺ţ<CBBA>");
|
||||
|
||||
//<2F><>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD>
|
||||
char account_input[20];
|
||||
fflush(stdin);
|
||||
scanf("%s",&account_input);
|
||||
|
||||
struct user *head,*p,*q;
|
||||
head=(struct user *) malloc(sizeof(struct user));
|
||||
q=head;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD><CBBA>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
||||
FILE *fp;
|
||||
fp = fopen("../users/users.txt", "r");
|
||||
while (!feof(fp)){
|
||||
p=(struct user *)malloc(sizeof(struct user));
|
||||
fscanf(fp,"%s %s",&p->account,&p->password);
|
||||
q->next=p;
|
||||
q=p;
|
||||
}
|
||||
fclose(fp);
|
||||
p->next=NULL;
|
||||
|
||||
//<2F>ж<EFBFBD><D0B6>˺<EFBFBD><CBBA>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
int account_exist=0;
|
||||
p=head->next;
|
||||
while (p!=NULL){
|
||||
//<2F>˺Ŵ<CBBA><C5B4><EFBFBD>
|
||||
if(strcmp(account_input,p->account)==0){
|
||||
//<2F><>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
char password[20];
|
||||
int password_input_count=0;
|
||||
re_input_password:
|
||||
printf("-> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룺");
|
||||
fflush(stdin);
|
||||
scanf("%s",&password);
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ
|
||||
if(strcmp(password,p->password)==0){
|
||||
//<2F><>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>
|
||||
account_exist=1;
|
||||
secondary_menu();
|
||||
break;
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
else{
|
||||
password_input_count++;
|
||||
if(password_input_count<3){
|
||||
printf("-><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD>\n");
|
||||
fflush(stdin);
|
||||
goto re_input_password;
|
||||
}
|
||||
else{
|
||||
printf("-><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>࣬<EFBFBD><E0A3AC><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD>ԡ<EFBFBD>\n");
|
||||
fflush(stdin);
|
||||
Sleep(2000);
|
||||
main();
|
||||
}
|
||||
}
|
||||
}
|
||||
p=p->next;
|
||||
}
|
||||
//<2F>˺Ų<CBBA><C5B2><EFBFBD><EFBFBD><EFBFBD>
|
||||
if(account_exist!=1){
|
||||
re_input_whether_registered:
|
||||
printf("-><3E>˺Ų<CBBA><C5B2><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD><E1A3BF>y/n<><6E>");
|
||||
char whether_registered;
|
||||
fflush(stdin);
|
||||
scanf("%c",&whether_registered);
|
||||
switch (whether_registered) {
|
||||
//<2F><>ת<EFBFBD><D7AA>ע<EFBFBD><D7A2>ģ<EFBFBD><C4A3>
|
||||
case 'y':{
|
||||
registered_module();
|
||||
break;
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>
|
||||
case 'n':{
|
||||
main();
|
||||
}
|
||||
//<2F><><EFBFBD>벻<EFBFBD>Ϸ<EFBFBD>
|
||||
default:{
|
||||
printf("-><3E><><EFBFBD>벻<EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룡\n");
|
||||
fflush(stdin);
|
||||
goto re_input_whether_registered;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user