choi

Add the bulletin update function

...@@ -53,4 +53,25 @@ router.get('/read/:idx', function(req,res,next){ ...@@ -53,4 +53,25 @@ router.get('/read/:idx', function(req,res,next){
53 }) 53 })
54 }) 54 })
55 55
56 +router.post('/update', function(req,res,next){
57 + var idx = req.body.idx
58 + var name = req.body.name
59 + var title = req.body.title
60 + var content = req.body.content
61 + var passwd = req.body.passwd
62 + var datas = [name, title, content, idx, passwd]
63 +
64 + var sql = "update board set name = ?,title=?,content=?,modidate=now() where idx =? and passwd=?"
65 + board.query(sql,datas,function(err,result){
66 + if(err) console.error(err)
67 + if(result.affectedRows==0){
68 + res.send("<script>alert('패스워드가 일치하지 않습니다.');history.back();</script>")
69 + }
70 + else
71 + {
72 + res.redirect('/board/read/'+idx)
73 + }
74 + })
75 +})
76 +
56 module.exports = router; 77 module.exports = router;
...\ No newline at end of file ...\ No newline at end of file
......