unknown

myprofile

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