-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLog_in Portal.c
125 lines (109 loc) · 2.19 KB
/
Log_in Portal.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
typedef struct Data{
char name[50];
int admn,cia;
char usn[20];
}data;
void registration()
{
data *m,*c;
FILE *p;
p = fopen("admin.bin","ab+");
c = (data*)malloc(sizeof(data));
m = (data*)malloc(sizeof(data));
printf("\n");
a:printf("Enter the Student's Admission Number:- ");
scanf("%d",&m->admn);
if(m->admn==0)
{
printf("\t\t\t\tReturning to Main Menu...");
Sleep(1000);
system("cls");
return;
}
fflush(stdin);
printf("Enter the Student's USN:- ");
scanf("%s",m->usn);
rewind(p);
for(;;)
{
fread(c,sizeof(data),1,p);
if(feof(p))
break;
else if((m->admn==c->admn)||(strcmp(m->usn,c->usn)==0))
{
printf("\t\t\t\t\tALREADY REGISTERED..\n\n");
goto a;
}
}
printf("Enter student's name\n");
fflush(stdin);
gets(m->name);
fwrite(m,sizeof(data),1,p);
fclose(p);
free(m);
free(c);
printf("\n\t\t\t\t\t...DATABASE UPDATED SUCCESSFULLY...\n\n");
}
int signin()
{
FILE *p;
p = fopen("admin.bin","ab+");
int flag=0;
data *m,*c;
m = (data*)malloc(sizeof(data));
c = (data*)malloc(sizeof(data));
again:printf("Enter your Login Id : ");
scanf("%s",m->usn);
printf("Enter your Password : ");
scanf("%d",&m->admn);
rewind(p);
for(;;)
{
fread(c,sizeof(data),1,p);
if(feof(p))
break;
else if((strcmp(m->usn,c->usn)!=0)||(m->admn!=c->admn))
flag=1;
else
return(c->admn);
}
if(flag==1)
{
printf("\t\t\t\t\tGive correct credentials....\n");
goto again;
}
}
main()
{
int choice, choose, w;
printf("\t\t\t\tWelcome To Student Portal\n\n");
a:printf("1.Registration\t\t2.Sign In\t\t3.Exit\n");
scanf("%d",&choice);
switch(choice)
{
case 1:registration();
break;
case 2: w = signin();
system("cls");
printf("1.Tests\t\t2.Scores\n");
scanf("%d",&choose);
switch(choose)
{
// case 1:
// test(w); //Used to link this main interface with Student portal.
// break;
// case 2:
// score_card(w); //Score Portal not coded
// break;
}
break;
case 3:
printf("Bye!\n");
Sleep(2000);
exit(0);
}
goto a;
}