Mukho

Fix Bug and Update DB

...@@ -9,7 +9,7 @@ module.exports=function(){ ...@@ -9,7 +9,7 @@ module.exports=function(){
9 port:'3306', 9 port:'3306',
10 user:'root', 10 user:'root',
11 password:'', 11 password:'',
12 - database:'userdb' 12 + database:'singer_composer'
13 // host:config.host, 13 // host:config.host,
14 // port:config.port, 14 // port:config.port,
15 // user:config.user, 15 // user:config.user,
......
...@@ -5,7 +5,7 @@ module.exports=(function(){ ...@@ -5,7 +5,7 @@ module.exports=(function(){
5 port:'3306', 5 port:'3306',
6 user:'root', 6 user:'root',
7 password:'', 7 password:'',
8 - database:'userdb' 8 + database:'singer_composer'
9 }, 9 },
10 example: { 10 example: {
11 host: '', 11 host: '',
......
...@@ -40,38 +40,7 @@ ...@@ -40,38 +40,7 @@
40 <div class="text-center text-white"> 40 <div class="text-center text-white">
41 <!-- Page heading--> 41 <!-- Page heading-->
42 <h1 class="mb-5">묵호가 만든 놀이터다. 작곡가와 가수가 서로 연결되는데 그 목적이 있다.</h1> 42 <h1 class="mb-5">묵호가 만든 놀이터다. 작곡가와 가수가 서로 연결되는데 그 목적이 있다.</h1>
43 - <!-- Signup form--> 43 + <iframe width="560" height="315" src="https://www.youtube.com/embed/wgbr7exUnzE" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
44 - <!-- * * * * * * * * * * * * * * *-->
45 - <!-- * * SB Forms Contact Form * *-->
46 - <!-- * * * * * * * * * * * * * * *-->
47 - <!-- This form is pre-integrated with SB Forms.-->
48 - <!-- To make this form functional, sign up at-->
49 - <!-- https://startbootstrap.com/solution/contact-forms-->
50 - <!-- to get an API token!-->
51 - <form class="form-subscribe" id="contactForm" data-sb-form-api-token="API_TOKEN">
52 - <!-- ID input-->
53 - <div class="row">
54 - <div class="row">
55 - <a class="btn btn-primary" href="/board/list">임시게시판</a>
56 - </div>
57 - </div>
58 - <!-- Submit success message-->
59 - <!---->
60 - <!-- This is what your users will see when the form-->
61 - <!-- has successfully submitted-->
62 - <div class="d-none" id="submitSuccessMessage">
63 - <div class="text-center mb-3">
64 - <div class="fw-bolder">Form submission successful!</div>
65 - <p>To activate this form, sign up at</p>
66 - <a class="text-white" href="https://startbootstrap.com/solution/contact-forms">https://startbootstrap.com/solution/contact-forms</a>
67 - </div>
68 - </div>
69 - <!-- Submit error message-->
70 - <!---->
71 - <!-- This is what your users will see when there is-->
72 - <!-- an error submitting the form-->
73 - <div class="d-none" id="submitErrorMessage"><div class="text-center text-danger mb-3">Error sending message!</div></div>
74 - </form>
75 </div> 44 </div>
76 </div> 45 </div>
77 </div> 46 </div>
......
...@@ -23,17 +23,26 @@ DB 구조(*ID, password, type) -> 형식에 맞게 추가<br> ...@@ -23,17 +23,26 @@ DB 구조(*ID, password, type) -> 형식에 맞게 추가<br>
23 추가된 형식에 맞는 로그인 및 세션 등 변경<br> 23 추가된 형식에 맞는 로그인 및 세션 등 변경<br>
24 alter table userDB add nickname varchar(20) not null;<br> 24 alter table userDB add nickname varchar(20) not null;<br>
25 25
26 -CREATE TABLE `board` ( 26 +Database = singer_composer
27 - `idx` int(11) NOT NULL AUTO_INCREMENT, 27 +
28 - `name` varchar(50) NOT NULL, 28 +create table userdb(
29 - `title` varchar(50) NOT NULL, 29 + ID varchar(20) not null primary key,
30 - `content` mediumtext NOT NULL, 30 + password varchar(20) not null,
31 - `regdate` datetime NOT NULL, 31 + type varchar(10) not null,
32 - `modidate` datetime NOT NULL, 32 + nickname varchar(20) not null,
33 - `passwd` varchar(50) NOT NULL, 33 + profilemsg varchar(300)
34 - `hit` int(11) NOT NULL DEFAULT '0', 34 +)engine=innodb;
35 - PRIMARY KEY (`idx`) 35 +
36 -);<br><br> 36 +create table board(
37 + idx int not null primary key auto_increment,
38 + name varchar(50) not null,
39 + title varchar(50) not null,
40 + content mediumtext not null,
41 + regdate datetime not null,
42 + modidate datetime not null,
43 + passwd varchar(50) not null,
44 + hit int not null
45 +)engine=innodb;<br><br>
37 46
38 DB구조 - board에서 사용됨(*idx, name, title, content, regdate, modidate, passwd, hit)<br> 47 DB구조 - board에서 사용됨(*idx, name, title, content, regdate, modidate, passwd, hit)<br>
39 *idx int, name varchar(50), title varchar(50), content mediumtext, regdate datetime, modidate datetime, passwd varchar(50), hit int<br> 48 *idx int, name varchar(50), title varchar(50), content mediumtext, regdate datetime, modidate datetime, passwd varchar(50), hit int<br>
...@@ -42,6 +51,6 @@ DB구조 - board에서 사용됨(*idx, name, title, content, regdate, modidate, ...@@ -42,6 +51,6 @@ DB구조 - board에서 사용됨(*idx, name, title, content, regdate, modidate,
42 LF 오류시 git config --global core.autocrlf true 입력<br><br> 51 LF 오류시 git config --global core.autocrlf true 입력<br><br>
43 52
44 53
45 -최종 수정: 2021-11-19 12:19<br> 54 +최종 수정: 2021-11-19 02:23<br>
46 -최종 수정 내용: 메뉴바/하단 추가, 게시판에 기본 서식 추가, 로그인시에만 게시판 관련 경로에 접근가능하게 함, 사용자 로그 생성<br> 55 +최종 수정 내용: 프로필 추가, 메뉴바/하단 추가, 게시판에 기본 서식 추가, 로그인시에만 게시판 관련 경로에 접근가능하게 함, 사용자 로그 생성<br>
47 수정 내용: 경로 지정 수정, 제목 추가, userDB, 회원가입에 nickname요소 추가, 세션에 ID + 닉네임 전달기능 추가, 게시판의 글쓰기 및 글 열람 기능 추가. 56 수정 내용: 경로 지정 수정, 제목 추가, userDB, 회원가입에 nickname요소 추가, 세션에 ID + 닉네임 전달기능 추가, 게시판의 글쓰기 및 글 열람 기능 추가.
......
...@@ -15,11 +15,7 @@ router.get('/list/:page', function(req, res, next) { ...@@ -15,11 +15,7 @@ router.get('/list/:page', function(req, res, next) {
15 else{ 15 else{
16 var page = req.params.page; 16 var page = req.params.page;
17 var sql = "select idx, name, title, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " + 17 var sql = "select idx, name, title, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " +
18 -<<<<<<< HEAD 18 + "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate, hit from board";
19 - "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate from userdb.board";
20 -=======
21 - "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate,hit from board";
22 ->>>>>>> c29f2a5d1c3813d7d5c357acc015b4d40a6e701d
23 19
24 board.query(sql, function(err,rows) { 20 board.query(sql, function(err,rows) {
25 if (err) console.error("err : " + err); 21 if (err) console.error("err : " + err);
...@@ -31,7 +27,6 @@ router.get('/list/:page', function(req, res, next) { ...@@ -31,7 +27,6 @@ router.get('/list/:page', function(req, res, next) {
31 } 27 }
32 }); 28 });
33 29
34 -
35 router.get('/list', function(req,res,next){ 30 router.get('/list', function(req,res,next){
36 var id = req.user; 31 var id = req.user;
37 if(!id) res.sendFile(path.join(__dirname, "../../public/login.html")) 32 if(!id) res.sendFile(path.join(__dirname, "../../public/login.html"))
...@@ -56,7 +51,7 @@ router.post('/write', function(req,res,next){ ...@@ -56,7 +51,7 @@ router.post('/write', function(req,res,next){
56 var passwd = req.body.passwd 51 var passwd = req.body.passwd
57 var datas = [name,title,content,passwd] 52 var datas = [name,title,content,passwd]
58 53
59 - var sql = "insert into board(name, title, content, regdate, modidate, passwd,hit) values(?,?,?,now(),now(),?,0)"; 54 + var sql = "insert into board(name, title, content, regdate, modidate, passwd, hit) values(?,?,?,now(),now(),?,0)";
60 board.query(sql,datas, function (err, rows) { 55 board.query(sql,datas, function (err, rows) {
61 if (err) console.error("err : " + err); 56 if (err) console.error("err : " + err);
62 57
...@@ -70,7 +65,7 @@ router.post('/write', function(req,res,next){ ...@@ -70,7 +65,7 @@ router.post('/write', function(req,res,next){
70 router.get('/read/:idx', function(req,res,next){ 65 router.get('/read/:idx', function(req,res,next){
71 var idx = req.params.idx 66 var idx = req.params.idx
72 var sql = "select idx, name, title, content, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " + 67 var sql = "select idx, name, title, content, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " +
73 - "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate,hit from userdb.board where idx=?"; 68 + "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate, hit from board where idx=?";
74 board.query(sql,[idx], function(err,row){ 69 board.query(sql,[idx], function(err,row){
75 if(err) console.error(err) 70 if(err) console.error(err)
76 71
......
...@@ -12,7 +12,7 @@ var connection = mysql.createConnection({ ...@@ -12,7 +12,7 @@ var connection = mysql.createConnection({
12 port : 3306, 12 port : 3306,
13 user: 'root', 13 user: 'root',
14 password : '', 14 password : '',
15 - database : 'userDB' 15 + database : 'singer_composer'
16 }) 16 })
17 connection.connect(); 17 connection.connect();
18 18
......
...@@ -15,23 +15,23 @@ router.get('/', function(req, res){ ...@@ -15,23 +15,23 @@ router.get('/', function(req, res){
15 myinfo.query(sql,[id],function(err,rows) { 15 myinfo.query(sql,[id],function(err,rows) {
16 if (err) console.error("err : " + err); 16 if (err) console.error("err : " + err);
17 var nickname = req.user.nickname; 17 var nickname = req.user.nickname;
18 - var job = rows[0].type; 18 + var type = rows[0].type;
19 var profilemsg = rows[0].profilemsg; 19 var profilemsg = rows[0].profilemsg;
20 - console.log(req.user.ID+'('+nickname+') 유저가 myProfile을 보고있습니다.') 20 + console.log(req.user.ID+'('+nickname+') 유저가 프로필을 보고있습니다.')
21 - res.render('profile.ejs', {'ID':id, 'nickname': nickname, 'profilemsg': profilemsg, 'job': job}) 21 + res.render('profile.ejs', {'ID':id, 'nickname': nickname, 'profilemsg': profilemsg, 'type': type})
22 }) 22 })
23 } 23 }
24 }); 24 });
25 25
26 router.get('/update', function(req,res){ 26 router.get('/update', function(req,res){
27 - var sql = "select profilemsg from userdb"; 27 + var sql = 'select profilemsg from userdb where id ="'+req.user.ID+'"';
28 28
29 myinfo.query(sql, function(err,rows) { 29 myinfo.query(sql, function(err,rows) {
30 if (err) console.error("err : " + err); 30 if (err) console.error("err : " + err);
31 var id = req.user.ID; 31 var id = req.user.ID;
32 var nickname = req.user.nickname; 32 var nickname = req.user.nickname;
33 var profilemsg = rows[0].profilemsg; 33 var profilemsg = rows[0].profilemsg;
34 - res.render('profmsgedit.ejs', {'ID':id, 'nickname': nickname, 'profilemsg':profilemsg}); 34 + res.render('profmsgedit.ejs', {'ID':id, 'nickname': nickname, 'profilemsg': profilemsg});
35 }) 35 })
36 36
37 }) 37 })
...@@ -46,6 +46,8 @@ router.post('/update', function(req,res,next){ ...@@ -46,6 +46,8 @@ router.post('/update', function(req,res,next){
46 var sql = "update userdb set profilemsg =?, nickname=?, type=? where id =?" 46 var sql = "update userdb set profilemsg =?, nickname=?, type=? where id =?"
47 myinfo.query(sql,datas,function(err,result){ 47 myinfo.query(sql,datas,function(err,result){
48 if(err) console.error(err) 48 if(err) console.error(err)
49 +
50 + console.log(req.user.ID+'('+nickname+') 유저가 프로필을 수정했습니다.')
49 res.redirect('/profile') 51 res.redirect('/profile')
50 }) 52 })
51 }) 53 })
......
...@@ -12,7 +12,7 @@ var connection = mysql.createConnection({ ...@@ -12,7 +12,7 @@ var connection = mysql.createConnection({
12 port : 3306, 12 port : 3306,
13 user: 'root', 13 user: 'root',
14 password : '', 14 password : '',
15 - database : 'userDB' 15 + database : 'singer_composer'
16 }) 16 })
17 connection.connect(); 17 connection.connect();
18 18
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
27 <li><a href="#" class="nav-link px-2 link-dark">???(미구현)</a></li> 27 <li><a href="#" class="nav-link px-2 link-dark">???(미구현)</a></li>
28 </ul> 28 </ul>
29 <div class="user"> 29 <div class="user">
30 - <a> <%= nickname %> 님 안녕하세요 </section></a> 30 + <a href = "/profile"> <%=nickname%></a><a>님 안녕하세요</a>
31 <a class="btn btn-primary" href="/logout">로그아웃</a> 31 <a class="btn btn-primary" href="/logout">로그아웃</a>
32 </div> 32 </div>
33 </div> 33 </div>
...@@ -44,9 +44,9 @@ ...@@ -44,9 +44,9 @@
44 <td>등록일</td> 44 <td>등록일</td>
45 </tr> 45 </tr>
46 <% 46 <%
47 - for(var i = (page * page_num) - page_num; i < (page * page_num); i++) { 47 + for(var i = (page * page_num)-1; i >= (page * page_num) - page_num; i--) {
48 - if(i > length){ 48 + if(i >= length){
49 - i++; 49 + i--;
50 }else{ 50 }else{
51 var data = rows[i] 51 var data = rows[i]
52 %> 52 %>
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
27 <li><a href="#" class="nav-link px-2 link-dark">???(미구현)</a></li> 27 <li><a href="#" class="nav-link px-2 link-dark">???(미구현)</a></li>
28 </ul> 28 </ul>
29 <div class="user"> 29 <div class="user">
30 - <a href = "/profile"> <%=nickname%></a><a>님 안녕하세요 </a> 30 + <a href = "/profile"> <%=nickname%></a><a>님 안녕하세요</a>
31 <a class="btn btn-primary" href="/logout">로그아웃</a> 31 <a class="btn btn-primary" href="/logout">로그아웃</a>
32 </div> 32 </div>
33 </div> 33 </div>
...@@ -40,36 +40,7 @@ ...@@ -40,36 +40,7 @@
40 <div class="text-center text-white"> 40 <div class="text-center text-white">
41 <!-- Page heading--> 41 <!-- Page heading-->
42 <h1 class="mb-5">묵호가 만든 놀이터다. 작곡가와 가수가 서로 연결되는데 그 목적이 있다.</h1> 42 <h1 class="mb-5">묵호가 만든 놀이터다. 작곡가와 가수가 서로 연결되는데 그 목적이 있다.</h1>
43 - <!-- Signup form--> 43 + <iframe width="560" height="315" src="https://www.youtube.com/embed/wgbr7exUnzE" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
44 - <!-- * * * * * * * * * * * * * * *-->
45 - <!-- * * SB Forms Contact Form * *-->
46 - <!-- * * * * * * * * * * * * * * *-->
47 - <!-- This form is pre-integrated with SB Forms.-->
48 - <!-- To make this form functional, sign up at-->
49 - <!-- https://startbootstrap.com/solution/contact-forms-->
50 - <!-- to get an API token!-->
51 - <form class="form-subscribe" id="contactForm" data-sb-form-api-token="API_TOKEN">
52 - <!-- ID input-->
53 - <div class="row">
54 - <a class="btn btn-primary" href="/board/list">임시게시판</a>
55 - </div>
56 - <!-- Submit success message-->
57 - <!---->
58 - <!-- This is what your users will see when the form-->
59 - <!-- has successfully submitted-->
60 - <div class="d-none" id="submitSuccessMessage">
61 - <div class="text-center mb-3">
62 - <div class="fw-bolder">Form submission successful!</div>
63 - <p>To activate this form, sign up at</p>
64 - <a class="text-white" href="https://startbootstrap.com/solution/contact-forms">https://startbootstrap.com/solution/contact-forms</a>
65 - </div>
66 - </div>
67 - <!-- Submit error message-->
68 - <!---->
69 - <!-- This is what your users will see when there is-->
70 - <!-- an error submitting the form-->
71 - <div class="d-none" id="submitErrorMessage"><div class="text-center text-danger mb-3">Error sending message!</div></div>
72 - </form>
73 </div> 44 </div>
74 </div> 45 </div>
75 </div> 46 </div>
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
26 <li><a href="#" class="nav-link px-2 link-dark">???(미구현)</a></li> 26 <li><a href="#" class="nav-link px-2 link-dark">???(미구현)</a></li>
27 </ul> 27 </ul>
28 <div class="user"> 28 <div class="user">
29 - <a> <%= nickname %> 님 안녕하세요 </section></a> 29 + <a href = "/profile"> <%=nickname%></a><a>님 안녕하세요</a>
30 <a class="btn btn-primary" href="/logout">로그아웃</a> 30 <a class="btn btn-primary" href="/logout">로그아웃</a>
31 </div> 31 </div>
32 </div> 32 </div>
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
41 <dt class = nic_tit>닉네임</dt> 41 <dt class = nic_tit>닉네임</dt>
42 <dd class = nic_ele><%=nickname%></dd> 42 <dd class = nic_ele><%=nickname%></dd>
43 <dt class = nic_tit>직종</dt> 43 <dt class = nic_tit>직종</dt>
44 - <dd class = nic_ele><%=job%></dd> 44 + <dd class = nic_ele><%=type%></dd>
45 <dt class = nic_tit>상태 메시지</dt> 45 <dt class = nic_tit>상태 메시지</dt>
46 <dd class = nic_ele><%=profilemsg%></dd> 46 <dd class = nic_ele><%=profilemsg%></dd>
47 </div> 47 </div>
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
26 <li><a href="#" class="nav-link px-2 link-dark">???(미구현)</a></li> 26 <li><a href="#" class="nav-link px-2 link-dark">???(미구현)</a></li>
27 </ul> 27 </ul>
28 <div class="user"> 28 <div class="user">
29 - <a> <%= nickname %> 님 안녕하세요 </section></a> 29 + <a href = "/profile"> <%=nickname%></a><a>님 안녕하세요</a>
30 <a class="btn btn-primary" href="/logout">로그아웃</a> 30 <a class="btn btn-primary" href="/logout">로그아웃</a>
31 </div> 31 </div>
32 </div> 32 </div>
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
24 <li><a href="#" class="nav-link px-2 link-dark">???(미구현)</a></li> 24 <li><a href="#" class="nav-link px-2 link-dark">???(미구현)</a></li>
25 </ul> 25 </ul>
26 <div class="user"> 26 <div class="user">
27 - <a> <%= nickname %> 님 안녕하세요 </section></a> 27 + <a href = "/profile"> <%=nickname%></a><a>님 안녕하세요</a>
28 <a class="btn btn-primary" href="/logout">로그아웃</a> 28 <a class="btn btn-primary" href="/logout">로그아웃</a>
29 </div> 29 </div>
30 </div> 30 </div>
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
23 <li><a href="#" class="nav-link px-2 link-dark">???(미구현)</a></li> 23 <li><a href="#" class="nav-link px-2 link-dark">???(미구현)</a></li>
24 </ul> 24 </ul>
25 <div class="user"> 25 <div class="user">
26 - <a> <%= nickname %> 님 안녕하세요 </section></a> 26 + <a href = "/profile"> <%=nickname%></a><a>님 안녕하세요</a>
27 <a class="btn btn-primary" href="/logout">로그아웃</a> 27 <a class="btn btn-primary" href="/logout">로그아웃</a>
28 </div> 28 </div>
29 </div> 29 </div>
......