unknown

myprofile

...@@ -11383,3 +11383,34 @@ footer.footer { ...@@ -11383,3 +11383,34 @@ footer.footer {
11383 padding-top: 4rem; 11383 padding-top: 4rem;
11384 padding-bottom: 4rem; 11384 padding-bottom: 4rem;
11385 } 11385 }
11386 +
11387 +#prof_con{
11388 + margin-top: 50px;
11389 + margin-left: 15%;
11390 + margin-right: 15%;
11391 + width: 70%;
11392 +}
11393 +
11394 +.column{
11395 + display: inline-block;
11396 + width: 48%;
11397 + margin-left: 5px;
11398 + margin-right: 5px;
11399 +}
11400 +
11401 +.bx_group{
11402 + margin-top: 15px;
11403 + border-radius: 1px;
11404 + border-color: rgb(153, 153, 153);
11405 + border-width: 1px;
11406 + padding: 20px;
11407 + border-style: solid;
11408 +}
11409 +
11410 +.wrap{
11411 + align-items: center;
11412 +}
11413 +
11414 +.info{
11415 +
11416 +}
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -8,8 +8,8 @@ module.exports=function(){ ...@@ -8,8 +8,8 @@ module.exports=function(){
8 host:'localhost', 8 host:'localhost',
9 port:'3306', 9 port:'3306',
10 user:'root', 10 user:'root',
11 - password:'2016104101', 11 + password:'',
12 - database:'board' 12 + database:'userdb'
13 // host:config.host, 13 // host:config.host,
14 // port:config.port, 14 // port:config.port,
15 // user:config.user, 15 // user:config.user,
......
...@@ -4,8 +4,8 @@ module.exports=(function(){ ...@@ -4,8 +4,8 @@ module.exports=(function(){
4 host:'localhost', 4 host:'localhost',
5 port:'3306', 5 port:'3306',
6 user:'root', 6 user:'root',
7 - password:'2016104101', 7 + password:'',
8 - database:'board' 8 + database:'userdb'
9 }, 9 },
10 example: { 10 example: {
11 host: '', 11 host: '',
......
...@@ -14,7 +14,7 @@ router.get('/list/:page', function(req, res, next) { ...@@ -14,7 +14,7 @@ router.get('/list/:page', function(req, res, next) {
14 else{ 14 else{
15 var page = req.params.page; 15 var page = req.params.page;
16 var sql = "select idx, name, title, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " + 16 var sql = "select idx, name, title, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " +
17 - "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate from board"; 17 + "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate from userdb.board";
18 18
19 board.query(sql, function(err,rows) { 19 board.query(sql, function(err,rows) {
20 if (err) console.error("err : " + err); 20 if (err) console.error("err : " + err);
...@@ -64,7 +64,7 @@ router.post('/write', function(req,res,next){ ...@@ -64,7 +64,7 @@ router.post('/write', function(req,res,next){
64 router.get('/read/:idx', function(req,res,next){ 64 router.get('/read/:idx', function(req,res,next){
65 var idx = req.params.idx 65 var idx = req.params.idx
66 var sql = "select idx, name, title, content, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " + 66 var sql = "select idx, name, title, content, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " +
67 - "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate,hit from board where idx=?"; 67 + "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate,hit from userdb.board where idx=?";
68 board.query(sql,[idx], function(err,row){ 68 board.query(sql,[idx], function(err,row){
69 if(err) console.error(err) 69 if(err) console.error(err)
70 70
......
...@@ -3,6 +3,8 @@ var app = express() ...@@ -3,6 +3,8 @@ var app = express()
3 var router = express.Router(); 3 var router = express.Router();
4 var path = require('path') 4 var path = require('path')
5 5
6 +
7 +var profile = require('./profile/index')
6 var main = require('./main/main') 8 var main = require('./main/main')
7 var register = require('./register/index') 9 var register = require('./register/index')
8 var login = require('./login/index') 10 var login = require('./login/index')
...@@ -21,5 +23,6 @@ router.use('/register', register) ...@@ -21,5 +23,6 @@ router.use('/register', register)
21 router.use('/login', login) 23 router.use('/login', login)
22 router.use('/logout', logout) 24 router.use('/logout', logout)
23 router.use('/board', board) 25 router.use('/board', board)
26 +router.use('/profile',profile)
24 27
25 module.exports = router; 28 module.exports = router;
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -11,7 +11,7 @@ var connection = mysql.createConnection({ ...@@ -11,7 +11,7 @@ var connection = mysql.createConnection({
11 host: 'localhost', 11 host: 'localhost',
12 port : 3306, 12 port : 3306,
13 user: 'root', 13 user: 'root',
14 - password : '2016104101', 14 + password : '',
15 database : 'userDB' 15 database : 'userDB'
16 }) 16 })
17 connection.connect(); 17 connection.connect();
......
1 +var express = require('express')
2 +var app = express()
3 +var router = express.Router();
4 +var path = require('path') // 상대경로
5 +var mysql_odbc = require('../../db/db_board')();
6 +var myinfo = mysql_odbc.init();
7 +
8 +// main page는 login이 된 상태(세션정보가 있을때만) 접근이 가능하게 하자 -> info에 구현해놓음.
9 +router.get('/', function(req, res){
10 + var id = req.user.ID;
11 + if(!id) res.sendFile(path.join(__dirname, "../../public/login.html"))
12 + if(id){
13 + var sql = "select profilemsg, type from userdb where id =?";
14 +
15 + myinfo.query(sql,[id],function(err,rows) {
16 + if (err) console.error("err : " + err);
17 + var nickname = req.user.nickname;
18 + var job = rows[0].type;
19 + var profilemsg = rows[0].profilemsg;
20 + console.log(req.user.ID+'('+nickname+') 유저가 myProfile을 보고있습니다.')
21 + res.render('profile.ejs', {'ID':id, 'nickname': nickname, 'profilemsg': profilemsg, 'job': job})
22 + })
23 + }
24 +});
25 +
26 +router.get('/update', function(req,res){
27 + var sql = "select profilemsg from userdb";
28 +
29 + myinfo.query(sql, function(err,rows) {
30 + if (err) console.error("err : " + err);
31 + var id = req.user.ID;
32 + var nickname = req.user.nickname;
33 + var profilemsg = rows[0].profilemsg;
34 + res.render('profmsgedit.ejs', {'ID':id, 'nickname': nickname, 'profilemsg':profilemsg});
35 + })
36 +
37 +})
38 +
39 +router.post('/update', function(req,res,next){
40 + var id = req.user.ID;
41 + var profilemsg = req.body.profilemsg;
42 + var nickname = req.body.nickname;
43 + var type = req.body.type;
44 + var datas = [profilemsg, nickname, type, id]
45 +
46 + var sql = "update userdb set profilemsg =?, nickname=?, type=? where id =?"
47 + myinfo.query(sql,datas,function(err,result){
48 + if(err) console.error(err)
49 + res.redirect('/profile')
50 + })
51 +})
52 +
53 +module.exports = router;
...\ No newline at end of file ...\ No newline at end of file
...@@ -11,7 +11,7 @@ var connection = mysql.createConnection({ ...@@ -11,7 +11,7 @@ var connection = mysql.createConnection({
11 host: 'localhost', 11 host: 'localhost',
12 port : 3306, 12 port : 3306,
13 user: 'root', 13 user: 'root',
14 - password : '2016104101', 14 + password : '',
15 database : 'userDB' 15 database : 'userDB'
16 }) 16 })
17 connection.connect(); 17 connection.connect();
......
...@@ -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%> 님 안녕하세요 </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>
......
1 +<!DOCTYPE html>
2 +<html lang="en">
3 +<head>
4 + <meta charset="utf-8" />
5 + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
6 + <meta name="description" content="" />
7 + <meta name="author" content="" />
8 + <title>내 정보</title>
9 + <!-- Favicon-->
10 + <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" />
11 + <!-- Bootstrap icons-->
12 + <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css" rel="stylesheet" type="text/css" />
13 + <!-- Google fonts-->
14 + <link href="https://fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css" />
15 + <!-- Core theme CSS (includes Bootstrap)-->
16 + <link href="/css/styles.css?after" rel="stylesheet" />
17 +</head>
18 +<body>
19 + <nav class="navbar navbar-light bg-light static-top">
20 + <div class="container">
21 + <a class="navbar-brand" href="/main">묵호의 놀이터</a>
22 + <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0">
23 + <li><a href="#" class="nav-link px-2 link-dark">About(미구현)</a></li>
24 + <li><a href="/board/list" class="nav-link px-2 link-dark">게시판</a></li>
25 + <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>
28 + <div class="user">
29 + <a> <%= nickname %> 님 안녕하세요 </section></a>
30 + <a class="btn btn-primary" href="/logout">로그아웃</a>
31 + </div>
32 + </div>
33 + </nav>
34 + <div id = "prof_con">
35 + <div class = "column">
36 + <div class = "bx_group">
37 + <div class = "bx_header">
38 + <h2>내 프로필</h2>
39 + </div>
40 + <div class = "bx_content">
41 + <dt class = nic_tit>닉네임</dt>
42 + <dd class = nic_ele><%=nickname%></dd>
43 + <dt class = nic_tit>직종</dt>
44 + <dd class = nic_ele><%=job%></dd>
45 + <dt class = nic_tit>상태 메시지</dt>
46 + <dd class = nic_ele><%=profilemsg%></dd>
47 + </div>
48 + </div>
49 + <div class = "bx_group">
50 + <div class = "bx_header">
51 + </div>
52 + <div class = "bx_content">
53 + <a class="btn btn-primary" href="/profile/update">수정</a>
54 + </div>
55 + </div>
56 +
57 + </div>
58 + </div>
59 +
60 +</body>
61 +</html>
...\ No newline at end of file ...\ No newline at end of file
1 +<!DOCTYPE html>
2 +<html lang="en">
3 +<head>
4 + <meta charset="utf-8" />
5 + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
6 + <meta name="description" content="" />
7 + <meta name="author" content="" />
8 + <title>정보 수정</title>
9 + <!-- Favicon-->
10 + <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" />
11 + <!-- Bootstrap icons-->
12 + <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css" rel="stylesheet" type="text/css" />
13 + <!-- Google fonts-->
14 + <link href="https://fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css" />
15 + <!-- Core theme CSS (includes Bootstrap)-->
16 + <link href="../css/styles.css?after" rel="stylesheet" />
17 +</head>
18 +<body>
19 + <nav class="navbar navbar-light bg-light static-top">
20 + <div class="container">
21 + <a class="navbar-brand" href="/main">묵호의 놀이터</a>
22 + <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0">
23 + <li><a href="#" class="nav-link px-2 link-dark">About(미구현)</a></li>
24 + <li><a href="/board/list" class="nav-link px-2 link-dark">게시판</a></li>
25 + <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>
28 + <div class="user">
29 + <a> <%= nickname %> 님 안녕하세요 </section></a>
30 + <a class="btn btn-primary" href="/logout">로그아웃</a>
31 + </div>
32 + </div>
33 + </nav>
34 + <div class = "wrap">
35 + <form action="/profile/update" method="post">
36 + <div class = "nick">닉네임</div>
37 + <textarea name="nickname" id="nickname" cols="30" rows="1" required><%=nickname%></textarea>
38 + <div class = "nick">상태메시지</div>
39 + <textarea name="profilemsg" id="profilemsg" cols="30" rows="3" required><%=profilemsg%></textarea>
40 + <select class="form-select" name="type" id="type" aria-label="사용자 유형">
41 + <option value="작곡가">작곡가</option>
42 + <option value="가수">가수</option>
43 + </select>
44 + <button class="btn btn-primary btn-lg" id="submitButton" type="submit">수정</button>
45 + </form>
46 + </div>
47 +</body>
48 +</html>
...\ No newline at end of file ...\ No newline at end of file