Toggle navigation
Toggle navigation
This project
Loading...
Sign in
최시원
/
Singer-Composer
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
choi
2021-11-18 23:37:46 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f4ed5dfed519bf6fee3fba8b965749d757ecadcf
f4ed5dfe
1 parent
0c63c788
add bulletin delete function
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
2 deletions
router/board/index.js
views/read.ejs
router/board/index.js
View file @
f4ed5df
...
...
@@ -105,4 +105,26 @@ router.post('/update', function(req,res,next){
})
})
router
.
post
(
'/delete'
,
function
(
req
,
res
,
next
){
var
idx
=
req
.
body
.
idx
var
passwd
=
req
.
body
.
passwd
var
datas
=
[
idx
,
passwd
]
var
sql
=
"delete from board where idx=? and passwd=?"
board
.
query
(
sql
,
datas
,
function
(
err
,
result
){
if
(
err
)
console
.
error
(
err
)
if
(
result
.
affectedRows
==
0
){
res
.
send
(
"<script>alert('패스워드가 일치하지 않습니다.');history.back();</script>"
);
}
else
{
var
id
=
req
.
user
.
ID
;
var
nickname
=
req
.
user
.
nickname
;
console
.
log
(
req
.
user
.
ID
+
'('
+
nickname
+
') 유저가 '
+
idx
+
'번 게시글을 삭제했습니다.'
)
res
.
redirect
(
'/board/list/'
);
}
})
})
module
.
exports
=
router
;
\ No newline at end of file
...
...
views/read.ejs
View file @
f4ed5df
...
...
@@ -31,7 +31,13 @@
</nav>
<div
class=
"container px-5 my-5"
>
<h1>
<
%= title %>
</h1>
<script>
function
submit2
(
frm
){
frm
.
action
=
"/board/delete"
;
frm
.
submit
();
return
true
;
}
</script>
<form
action=
"/board/update"
method=
"post"
>
<table
border=
"1"
>
<input
type=
"hidden"
name=
"idx"
value=
"<%=row.idx%>"
/>
...
...
@@ -64,8 +70,9 @@
<td>
<
%=row.hit%>
</td>
</tr>
<tr>
<td
colspan=
"
2
"
>
<td
colspan=
"
3
"
>
<button
type=
"submit"
>
글 수정
</button>
<button
type=
"summit"
onclick=
"return submit2(this.form);"
>
글 삭제
</button>
<a
href=
"/board/list"
>
목록
</a>
</td>
</tr>
...
...
@@ -102,6 +109,7 @@
</ul>
</div>
</div>
</div>
</footer>
</body>
...
...
Please
register
or
login
to post a comment