SMM
jlogin.h
Go to the documentation of this file.
1 #include<stdio.h>
2 #include<iostream>
3 #include<conio.h>
4 #include<string.h>
5 #include<process.h>
6 using namespace std;
7 COORD coord={0,0};
8 void gotoxy(int x,int y)
9 {
10  coord.X=x;
11  coord.Y=y;
12  SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
13  }
14 
15 
16 
17 
18 int login()
19 {
20  {
21  int c=0,i=0,j=0,c1=0,c2=0;
22  long int v;
23  char jk[31],s1[10],s2[31],s3[10],e,l;
24  FILE *f1,*f2,*f3;
25  f1=fopen("DATA.txt","r");
26  f2=fopen("pass.txt","r");
27 
28 
29 //*********************************************************************
30 // FOR ENTERING A NEW USERNAME
31 //*********************************************************************
32 lbl:
33  do
34  {
35  printf("\n\tEnter user name:");
36  scanf("%s",s1);
37  fseek(f1,0L,0);
38  fscanf(f1,"%c",&s3[0]);
39 
40 
41  while(s3[j]!=EOF)
42  {
43  j++;
44  fscanf(f1,"%c",&s3[j]);
45  if(s3[j]==32)
46  {
47  s3[j]='\0';
48  if(!strcmp(s3,s1))
49  {
50 
51  break;
52  }
53  c2++;
54  j=0;
55 
56  fscanf(f1,"%c",&s3[j]);
57  }
58  }
59  if(strcmp(s3,s1))
60  {
61  printf("\n\tuser name does not exists");
62  c2=0;
63  }
64  j=0;
65  }while(strcmp(s1,s3)!=0);
66 
67 
68 //*********************************************************************
69 // FOR ENTERING PASSWORD
70 //*********************************************************************
71  string pass="";
72  char ch;
73  int ng=0;
74 
75  do
76  {
77  restart:
78  printf("\n\tenter password:");
79  a:
80  pass="";
81  ch=_getch();
82  while(ch!=13)
83  {
84  if(ch!=8)
85  {
86  pass.push_back(ch);
87  cout<<"*";
88  //cout<<ch;
89  ch=_getch();
90  }
91  else{
92  // fseek(f2,-1,1);
93  goto a;
94  }
95  }
96  strcpy(s, pass.c_str());
97  v=11*c2;
98  fseek(f2,v,0);
99  fscanf(f2,"%c",&s2[j]);
100  while(s2[j]!=32)
101  {
102  j++;
103  fscanf(f2,"%c",&s2[j]);
104  }
105  s2[j]='\0';
106  //cout<<"\n\n\n"<<s2;system("pause");
107  if(strcmp(s2,s))
108  {
109  printf("\n\twrong password try again");
110  ng++;
111  if(ng==3)
112  {
113  system("cls");
114  goto lbl;
115  // login();
116  }
117  }
118 
119 
120  j=0;
121 
122  }while(strcmp(s2,jk)!=0);
123 
124  return 0;
125  }
126 }
127 
128 
129 //*********************************************************************
130 // FOR CREATING A NEW ACCOUNT
131 //*********************************************************************
132 
133 
134 
135 
136 void createacc()
137 {
138  int c=0,i=0,j=0,c1=0,c2=0;
139  long int v;
140  char s[10],s1[10],s2[10],s3[10],e;
141  FILE *f1,*f2,*f3,*f4;
142  f1= fopen("DATA.txt","a");
143  f2 = fopen("pass.txt","a");
144  f3=fopen("DATA.txt","r");
145 
146 
147 //*********************************************************************
148 // FOR CREATING A NEW USERNAME
149 //*********************************************************************
150  do
151  {
152  printf("\n\tEnter user name:");
153  scanf("%s",s1);
154 
155  fscanf(f3,"%c",&s3[0]);
156 
157  while(s3[j]!=EOF)
158  {
159  j++;
160  fscanf(f3,"%c",&s3[j]);
161  if(s3[j]==32)
162  {
163  s3[j]='\0';
164  if(!strcmp(s3,s1))
165  {
166  printf("\n\tUsername already exists");
167  break;
168  }
169  j=0;
170  fscanf(f3,"%c",&s3[j]);
171  }
172  }
173  }while(strcmp(s1,s3)==0);
174 
175  fprintf(f1,"%s ",s1);
176 
177 
178 //*********************************************************************
179 // FOR CREATING A NEW PASSWORD
180 //*********************************************************************
181  string pass="";
182  char ch;
183 
184  do
185  {
186  do
187  {
188  printf("\n\tenter password:");
189  b: pass="";
190  ch=_getch();
191  //ch=getchar();
192  while(ch!=13)
193  {
194  if(ch!=8)
195  {
196  pass.push_back(ch);
197  cout<<"*";
198  ch=_getch();
199  // ch=getchar();
200  }
201  else{
202  // fseek(f2,-1,1);
203  goto b;
204  }
205  }
206  strcpy(s, pass.c_str());
207  //cout<<s;system("pause");
208  if(strlen(s)<8)
209  {
210  printf("\n\tEnter password of 10 character");
211  }
212  if(strlen(s)>10)
213  {
214  printf("\n\tPassword should be equals to 10 characters.");
215  }
216  }while(strlen(s)<8 || strlen(s)>10);
217 
218  for(i=0;s[i]!='\0';i++)
219  {
220  if(s[i]=='@')
221  c1=1;
222  }
223  i=0;
224  if(c1!=1)
225  printf("\n\tPlease use atleast one time @ in password..");
226  }while(c1==0);
227 
228  do
229  {
230  printf("\n\tConfirm your password:");
231 
232  a:
233  ch=_getch();
234  pass="";
235  while(ch!=13)
236  {
237  if(ch!=8)
238  {
239  pass.push_back(ch);
240  cout<<"*";
241  ch=_getch();
242  }
243  else{
244  // fseek(f2,-1,1);
245  goto a;
246  }
247  }
248  strcpy(s2, pass.c_str());
249 
250  if(strcmp(s,s2)!=0)
251  {
252  printf("\n\tPassword don't match.");
253  }
254 
255  }while(strcmp(s,s2));
256 
257  for(i=strlen(s);i<10;i++)
258  {
259  s[i]=' ';
260  }
261  //printf("%s",s);cout<<endl;system("pause");
262  for(i=0;s[i]!='\0';i++){
263  fprintf(f2,"%c",s[i]);
264  }
265 
266  fprintf(f2," ",stdout);
267 
268  fclose(f3);
269  fclose(f2);
270  fclose(f1);
271  c1=0;
272  c2=2;
273 }
int login()
Definition: jlogin.h:18
void createacc()
Definition: jlogin.h:136
void gotoxy(int x, int y)
Definition: jlogin.h:8
COORD coord
Definition: jlogin.h:7