-
Notifications
You must be signed in to change notification settings - Fork 0
/
slip_no_12B.js
38 lines (34 loc) · 1 KB
/
slip_no_12B.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
const mysql = require("mysql");
const express = require("express");
const bodyParser = require("body-parser");
const encoder = bodyParser.urlencoded();
const app = express();
const con = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
database: "nodejs"
});
con.connect(function(error){
if (error) throw error
else console.log("connected")
});
app.get("/",function(req,res){
res.sendFile(__dirname + "/index.html");
})
app.post("/",encoder, function(req,res){
var username = req.body.username;
var password = req.body.password;
con.query("select * from loginuser where user_name = ? and user_pass = ?",[username,password],function(error,results,fields){
if (results.length > 0) {
res.redirect("/loggedine");
} else {
res.redirect("/");
}
res.end();
})
})
app.get("/loggedine",function(req,res){
res.sendFile(__dirname + "/loggedine.html")
})
app.listen(8080);