-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
272 lines (247 loc) · 7.39 KB
/
server.js
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
var express = require("express");
var http = require("http");
var path = require("path");
var bodyParser = require("body-parser");
var helmet = require("helmet");
var rateLimit = require("express-rate-limit");
var fs = require("fs");
const formidable = require("formidable");
var fileUpload = require("express-fileupload");
const mysql = require("mysql");
var mysqlConnection = mysql.createConnection({
host: "localhost",
user: "root",
password: "oracle",
database: "raj-db",
port: 3306,
multipleStatements: true,
});
var app = express();
var server = http.createServer(app);
const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // limit each IP to 100 requests per windowMs
});
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname, "./public/")));
app.use(helmet());
app.use(limiter);
app.get("/", function (req, res) {
res.sendFile(path.join(__dirname, "public/index.html"));
});
// Add
app.post("/newfeedback", function (req, res) {
console.log(req.body.Q1);
console.log(req.body.Courses);
mysqlConnection.query(
"INSERT INTO STUDENT_DETAILS(STUDENT_ID, ACADEMIC_YEAR, SEMESTER, BRANCH, SECTION, COURSE) VALUES(?,?,?,?,?,?)",
[
req.body.Roll,
req.body.Year,
req.body.Sem,
req.body.Roll,
req.body.Branch,
req.body.Sec,
req.body.Courses,
],
function (err, result, fields) {
if (err) throw err;
console.log("1 row inserted in Student D");
}
);
mysqlConnection.query(
" INSERT INTO FEEDBACK_DETAILS(FEEDBACK_DATE, STUDENT_ID, COURSE, Q1, Q21, Q22, Q23, Q24, Q25, Q3, Q4) VALUES(?,?,?,?,?,?,?,?,?,?,?)",
[
req.body.Date,
req.body.Roll,
req.body.Courses,
req.body.Q1,
req.body.Q21,
req.body.Q22,
req.body.Q23,
req.body.Q24,
req.body.Q25,
req.body.Q3,
req.body.Q4,
],
function (err, result, fields) {
if (err) throw err;
console.log("1 row inserted in Feedback D");
res.send(
"New data has been added into the database with ID " + req.body.Roll
);
}
);
});
app.post("/save", function (req, res) {
mysqlConnection.query(
"INSERT INTO STUDENT_FORM(JEE_ROLL_NO,DATE_OF_REG) VALUES(?,?)",
[req.body.jeeroll,req.body.regdate],
function (err, result, fields) {
if (err) throw err;
console.log("1 row inserted in Student Form");
}
);
mysqlConnection.query(
"INSERT INTO STUDENT_REG_DETAILS(JEE_ROLL_NO, SNAME, GENDER,BLOOD_GROUP,DOB,MOBILE1,EMAIL,AADHAR_NO,BRANCH,MINORITY,FATHER_NAME,FATHER_OCCUPATION,MOTHER_NAME,MOTHER_OCCUPATION,PARENT_MOBILE,HOSTEL_REQ,PHOTO,SIGN) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
[
req.body.jeeroll,
req.body.fname,
req.body.gender,
req.body.bloodgrp,
req.body.dob,
req.body.mobileno,
req.body.email,
req.body.aadharno,
req.body.branch,
req.body.minority,
req.body.fathername,
req.body.fatherocp,
req.body.mothername,
req.body.motherocp,
req.body.parentmob,
req.body.hostel,
req.body.d1,
req.body.sigpic,
],
function (err, result, fields) {
if (err) throw err;
console.log("1 row inserted in Student Registeration Details");
}
);
mysqlConnection.query(
"INSERT INTO STUDENT_DESEASE(JEE_ROLL_NO,CHRONIC_DISEASE,DETAILS) VALUES(?,?,?)",
[req.body.jeeroll, req.body.disease, req.body.diseasedetails],
function (err, result, fields) {
if (err) throw err;
console.log("1 row inserted in Student Desease");
}
);
mysqlConnection.query(
"INSERT INTO DD_DB(DD_NO,DD_DATE,DD_AMOUNT) VALUES(?,?,?)",
[req.body.jdd, req.body.jdate, req.body.jamount],
function (err, result, fields) {
if (err) throw err;
console.log("1 row inserted in DD Database");
}
);
mysqlConnection.query(
"INSERT INTO DD_DB(DD_NO,DD_DATE,DD_AMOUNT) VALUES(?,?,?)",
[req.body.idd, req.body.idate, req.body.iamount],
function (err, result, fields) {
if (err) throw err;
console.log("1 row inserted in DD Database");
}
);
mysqlConnection.query(
"INSERT INTO STUDENT_PAYMENTS( JEE_ROLL_NO,JOSSA_DD,INST_DD) VALUES(?,?,?)",
[req.body.jeeroll, req.body.jdd, req.body.idd],
function (err, result, fields) {
if (err) throw err;
console.log("1 row inserted in STUDENT PAYMENTS");
}
);
mysqlConnection.query(
"INSERT INTO STUDENT_10_DB(JEE_ROLL_NO,BOARD_NAME,PASSING_YEAR,PERCENTAGE) VALUES(?,?,?,?)",
[
req.body.jeeroll,
req.body.tenboard,
req.body.tenyear,
req.body.tenpercent,
],
function (err, result, fields) {
if (err) throw err;
console.log("1 row inserted in STUDENT 10 DB");
}
);
mysqlConnection.query(
"INSERT INTO STUDENT_12_DB(JEE_ROLL_NO,BOARD_NAME,SUBJECT,PASSING_YEAR,PERCENTAGE) VALUES(?,?,?,?,?)",
[
req.body.jeeroll,
req.body.twelveboard,
req.body.twelvesub,
req.body.twelveyear,
req.body.twelvepercent,
],
function (err, result, fields) {
if (err) throw err;
console.log("1 row inserted in STUDENT 12 DB");
}
);
mysqlConnection.query(
"INSERT INTO STUDENT_CURR_ADD(JEE_ROLL_NO,ADDRESS,CITY,STATE,PIN_CODE,PHONE) VALUES(?,?,?,?,?,?)",
[
req.body.jeeroll,
req.body.caddress,
req.body.ccity,
req.body.cstate,
req.body.cpincode,
req.body.cmobile,
],
function (err, result, fields) {
if (err) throw err;
console.log("1 row inserted in STUDENT CURR DB");
}
);
mysqlConnection.query(
"INSERT INTO STUDENT_PER_ADD(JEE_ROLL_NO,ADDRESS,CITY,STATE,PIN_CODE,PHONE) VALUES(?,?,?,?,?,?)",
[
req.body.jeeroll,
req.body.paddress,
req.body.pcity,
req.body.pstate,
req.body.ppincode,
req.body.pmobile,
],
function (err, result, fields) {
if (err) throw err;
console.log("1 row inserted in STUDENT PER DB");
}
);
mysqlConnection.query(
"INSERT INTO STUDENT_JEE_DETAILS(JEE_ROLL_NO,ALLOTMENT_ROUND,AIR,PERCENTILE,ALLOTMENT_CATEGORY,CANDIDATE_CATEGORY) VALUES(?,?,?,?,?,?)",
[
req.body.jeeroll,
req.body.allotment,
req.body.air,
req.body.percent,
req.body.acategory,
req.body.ccategory,
],
function (err, result, fields) {
if (err) throw err;
console.log("1 row inserted in STUDENT JEE DB");
}
);
mysqlConnection.query(
" INSERT INTO STUDENT_DOCUMENTS( JEE_ROLL_NO, ALLOTMENT_LETTER, JEE_RANK_CARD , PHOTO_ID , DOB , QEXAM, INCOME_CERTIFICATE, CAST_CERTIFICATE, CAST_VALIDITY , OBC_CERTIFICATE , DISABILITY_CERTIFICATE, TRANSFER_CERTIFICATE , MIGRATION_CERTIFICATE, AADHAR_CARD , GAP_CARD) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);",
[
req.body.jeeroll,
req.body.d1,
req.body.d2,
req.body.d3,
req.body.d4,
req.body.d5,
req.body.d6,
req.body.d7,
req.body.d8,
req.body.d9,
req.body.d10,
req.body.d11,
req.body.d12,
req.body.d13,
req.body.d14,
],
function (err, result, fields) {
if (err) throw err;
console.log("1 row inserted in STUDENT DOCUMENTS DB");
}
);
res.send(
"New data has been added into the database with ID " + req.body.jeeroll
);
});
server.listen(3000, function () {
console.log("server is listening on port: 3000");
});