-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontact.js
51 lines (37 loc) · 1 KB
/
contact.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
var express=require("express");
var mysql=require("mysql2");
var app=express();
app.listen(3000 || process.env.PORT,function()
{
console.log("Server Started");
})
app.use(express.static("public"));
app.get("/",function(req,resp)
{
resp.sendFile(process.cwd()+"/public/index.html");
})
var dbConfig={
host:"127.0.0.1",
user:"root",
password:"",
database:"portfolio"
}
var dbCon=mysql.createConnection(dbConfig);
dbCon.connect(function(err)
{
if(err==null)
console.log("Connected Successsfully")
else
resp.send(err);
})
app.get("/do-submit", function (req, resp) {
console.log(req.query);
dbCon.query("insert into contact(email,name,subject,mobile,dos,message) values(?,?,?,?,current_date(),?)", [req.query.kuchemail, req.query.kuchname, req.query.kuchsubject,req.query.kuchnumber,req.query.kuchmessage], function (err) {
if (err == null) {
resp.send("Submit successfully")
}
else {
resp.send(err);
}
})
})