Skip to content

Commit 958e92f

Browse files
authored
Add files via upload
1 parent c61bcb3 commit 958e92f

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

library.c

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include<conio.h>
44

55
void show_error(MYSQL *con);
6+
void users_show(void);
67
void addbooks(void);
78
int connection(void);
89
void addusers(void);
@@ -84,7 +85,18 @@ int main(int argc, char **argv)
8485
}
8586
else
8687
{
87-
database_connect();
88+
snprintf(query, MAX_STRING, "SELECT role FROM library.users WHERE username = '%s' AND password = '%s'", username, password);
89+
char users[10]= "user";
90+
MYSQL_RES *result = mysql_store_result(con);
91+
92+
if(result == users)
93+
{
94+
database_connect();
95+
}
96+
else
97+
{
98+
users_show();
99+
}
88100
}
89101

90102

@@ -102,7 +114,11 @@ void database_connect(void)
102114
show_error(con);
103115

104116

117+
<<<<<<< HEAD
118+
printf("\n*****************************You Logged in as Admin*********************************");
119+
=======
105120

121+
>>>>>>> c61bcb3795474c23e52e8c6c86969891abe8d48d
106122
printf("\n\nWhat do you want to do : \n");
107123
printf("1). Add Users\n");
108124
printf("2). Add Books Details \n");
@@ -155,7 +171,34 @@ void database_connect(void)
155171
}
156172

157173
}
174+
void users_show(void)
175+
{
176+
if(mysql_query(con, "CREATE DATABASE IF NOT EXISTS library;"))
177+
show_error(con);
178+
179+
if(mysql_query(con, "USE library;"))
180+
show_error(con);
181+
182+
if(mysql_query(con, "CREATE TABLE IF NOT EXISTS books(ID int(8) AUTO_INCREMENT,Name char(30),Author char(30),Quantity int(5),Price int(5), Rack_no int(5), PRIMARY KEY(ID));"))
183+
show_error(con);
184+
185+
printf("**************************You Logged in as a User******************************");
186+
printf("\n1). Show Books Details");
187+
printf("\n2). Exit");
188+
189+
int c = getchar();
190+
c=getchar();
191+
switch(c)
192+
{
193+
case '1':
194+
fetchdata();
195+
break;
158196

197+
case '2':
198+
exit(0);
199+
break;
200+
}
201+
}
159202
void addusers(void)
160203
{
161204
char username[30],password[20],fullname[30],users[10]= "user",user;

0 commit comments

Comments
 (0)