-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
41 lines (25 loc) · 904 Bytes
/
app.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
const express = require('express');
const mysql = require('mysql');
const cors = require('cors');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.json());
app.use(cors());
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '',
database : 'libraryusers'
});
connection.connect(function(err){
if (err) throw err;
console.log('connected');
});
app.post('/register', function(req,resp){
console.log( req.body);
var sql = "insert into users values(null,'"+ req.body.username +"', '"+ req.body.firstname +"','"+ req.body.lastname +"','"+ req.body.email +"','"+ req.body.mobile +"','"+ req.body.IdNo +"')"
connection.query(sql,function(err){
if (err) throw err;
});
});
app.listen(3000);