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-17 05:30:05 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a37d15e501e90647b0fa67a0f39bb52904d2d675
a37d15e5
1 parent
4b449bc5
add write function in board
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
3 deletions
router/board/index.js
views/write.ejs
router/board/index.js
View file @
a37d15e
var
express
=
require
(
'express'
);
const
{
connect
}
=
require
(
'http2'
);
var
router
=
express
.
Router
();
var
mysql
=
require
(
'mysql'
);
var
path
=
require
(
'path'
)
// 상대경로
...
...
@@ -6,7 +7,7 @@ var mysql_odbc = require('../../db/db_board')();
var
board
=
mysql_odbc
.
init
();
router
.
get
(
'/:page'
,
function
(
req
,
res
,
next
)
{
router
.
get
(
'/
list/
:page'
,
function
(
req
,
res
,
next
)
{
var
page
=
req
.
params
.
page
;
var
sql
=
"select idx, name, title, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, "
+
"date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate from board"
;
...
...
@@ -18,8 +19,26 @@ router.get('/:page', function(req, res, next) {
})
});
router
.
get
(
'/'
,
function
(
req
,
res
,
next
){
res
.
redirect
(
'/board/1'
)
router
.
get
(
'/list'
,
function
(
req
,
res
,
next
){
res
.
redirect
(
'/board/list/1'
)
})
router
.
get
(
'/write'
,
function
(
req
,
res
,
next
){
res
.
render
(
'write.ejs'
,
{
title
:
"게시판 글 쓰기"
})
})
router
.
post
(
'/write'
,
function
(
req
,
res
,
next
){
var
name
=
req
.
body
.
name
var
title
=
req
.
body
.
title
var
content
=
req
.
body
.
content
var
passwd
=
req
.
body
.
passwd
var
datas
=
[
name
,
title
,
content
,
passwd
]
var
sql
=
"insert into board(name, title, content, regdate, modidate, passwd,hit) values(?,?,?,now(),now(),?,0)"
;
board
.
query
(
sql
,
datas
,
function
(
err
,
rows
)
{
if
(
err
)
console
.
error
(
"err : "
+
err
);
res
.
redirect
(
'/board/list/1'
);
});
})
module
.
exports
=
router
;
\ No newline at end of file
...
...
views/write.ejs
0 → 100644
View file @
a37d15e
<!DOCTYPE html>
<html>
<head>
<title>
<
%= title %>
</title>
<link
rel=
'stylesheet'
href=
'/stylesheets/style.css'
/>
</head>
<body>
<h1>
<
%= title %>
</h1>
<form
action=
"/board/write"
method=
"post"
>
<table
border=
"1"
>
<tr>
<td>
작성자
</td>
<td><input
type=
"text"
name=
"name"
id=
"name"
required
/></td>
</tr>
<tr>
<td>
제목
</td>
<td><input
type=
"text"
name=
"title"
id=
"title"
required
/></td>
</tr>
<tr>
<td>
내용
</td>
<td><textarea
name=
"content"
id=
"content"
cols=
"30"
rows=
"10"
required
></textarea></td>
</tr>
<tr>
<td>
패스워드
</td>
<td><input
type=
"password"
name=
"passwd"
id=
"passwd"
required
/></td>
</tr>
<tr>
<td
colspan=
"2"
>
<button
type=
"submit"
>
글쓰기
</button>
</td>
</tr>
</table>
</form>
</body>
</html>
\ No newline at end of file
Please
register
or
login
to post a comment