Waste Management System: Dbms Project 15CSE302
Waste Management System: Dbms Project 15CSE302
Waste Management System: Dbms Project 15CSE302
15CSE302
Group details
1) Nikish Kumar S. V. (CB.EN.U4CSE17440)
2) Nithin Aakash (CB.EN.U4CSE17443)
3) Sahisnu S. (CB.EN.U4CSE17450)
4) Sanjay Tharagesh R. S. (CB.EN.U4CSE17453)
Frontend software details
The frontend of the project is developed as minimalistic, elegant and
interactive user interface. It is very simple to use for any kind of user.
The technology stack used for developing the front end application
are as follows
1) HTML
2) CSS
3) Bootstrap
4) JavaScript
Frontend
Backend
1) AWS RDS database running on Amazon cloud platform
2) Server code to handle user and admin requests
Sample Code
Importing necessary libraries
var express = require("express");
var bodyParser = require("body-parser");
var mysql = require("mysql");
var fs = require('fs');
});
app.get('/user', function (req, res) {
//res.sendFile('__dirname','first.html');
res.sendFile('/home/nithu/myapp/dbms/index.html');
});
app.get('/admin', function (req, res) {
//res.sendFile('__dirname','first.html');
res.sendFile('/home/nithu/myapp/dbms/admin_login/index.html');
});
app.get('/register_user', function (req, res) {
//res.sendFile('__dirname','first.html');
res.sendFile('/home/nithu/myapp/dbms/user_reg.html');
});
Authentication
app.post('/ulogin', function (req, res) {
let user_name = req.body.username;
let user_password = req.body.password;
console.log(user_name + " " + user_password);
connection.query('SELECT u_password FROM client WHERE user_id="' +
user_name + '";', function (err, result, fields) {
if (err) throw err;
console.log("data retrieved");
let r = result[0].u_password;
console.log(r);
if (user_password != r)
res.send('Authentication failed');
else
res.sendFile('/home/nithu/myapp/dbms/user_dash.html');
});
});
app.post('/alogin', function (req, res) {
let admin_name = req.body.adminname;
let admin_password = req.body.password;
console.log(admin_name + " " + admin_password);
connection.query('SELECT a_password FROM admin WHERE admin_id="' +
admin_name + '";', function (err, result, fields) {
if (err) throw err;
console.log("data retrieved");
let r = result[0].a_password;
console.log(r);
if (admin_password != r)
res.send('Authentication failed');
else
res.sendFile('/home/nithu/myapp/dbms/admin_dash.html');
});
});
Updating database
app.post('/alogin/area_details/alogi2n', function (req, res) {
let admin_name = req.body.id;
let admin_password = req.body.field2;
let ad1=req.body.field3;
let ad2=req.body.field4;
console.log("asdas");
console.log(admin_name + " " + admin_password+ad1+ad2);
var sql1 =
"INSERT INTO area (area_id,name,latitude,longitude) VALUES ('"
+
req.body.id +
"','" +
req.body.field2 +
"','" +
req.body.field3+
"','" +
req.body.field4+
"');";
connection.query(sql1, function(err, result) {
console.log(sql1);
if (err) throw err;
console.log("1 record inserted");
res.send("area Added");
});
});
app.post('/alogin/area_details/alogi3n', function (req, res) {
let admin_name = req.body.field1;
let admin_password = req.body.field2;
let ad1=req.body.field3;
let ad2=req.body.field4;
console.log("asdas22");
console.log(admin_name + " " + admin_password+" "+ad1+" "+ad2);
var sql1 =
"UPDATE area set name='"+admin_password+"',latitude='"+ad1+"'
,longitude='"+ad2+"' where area_id='"+admin_name+"';"
connection.query(sql1, function(err, result) {
console.log(sql1);
if (err) throw err;
console.log("1 Area updated");
res.send("area updated");
});
});
app.post('/alogin/area_details/alogi4n', function (req, res) {
let admin_name = req.body.field1;
console.log("asdas22");
console.log(admin_name );
var sql1 =
"Delete from area where area_id='"+admin_name+"';"
connection.query(sql1, function(err, result) {
console.log(sql1);
if (err) throw err;
console.log("1Area updated");
res.send("area Deleted");
});
});
Server hosting
var server = app.listen(3000, function () {
console.log('Node server is running on port 3000');
});
Conclusion