-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
135 lines (121 loc) · 4.27 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!DOCTYPE html>
<html lang="ko">
<head>
<title> SmallCommunityProject </title>
<meta charset="utf-8" content-type="application/json" />
</head>
<link rel="stylesheet" href="./view/css/all.css">
<script>
window.onload = function(){
HttpRequest();
//httpRequest로 데이터 보내기 (withDataPageRouting.php에만 적용)
function HttpRequest(){
const Data = JSON.stringify({
pageURL: "SessionVerify"
});
const url = "/controller/withDataPageRoute.php?data=" + Data;
request = new XMLHttpRequest();
request.open("POST", url, true);
request.setRequestHeader("Content-type", "application/json");
request.send(); //$_GET['data']
//get response
request.onreadystatechange = function() {
if(request.readyState===XMLHttpRequest.DONE){
console.log(request.response); //Debuging
const loginDIV = document.getElementById("loginDIV");
const logoutDIV = document.getElementById("logoutDIV");
if(request.response !== "false") {
const id = request.response;
//세션값 정상
const userIDinfo = document.getElementById("userIDinfo");
userIDinfo.innerHTML = "안녕하세요! " + id + "님!";
loginDIV.style.display = "none";
logoutDIV.style.display = "block";
}
else{
loginDIV.style.display = "block";
logoutDIV.style.display = "none";
}
//조건이 거짓이라면 비로그인이거나 세션값이 비정상임
}
}
}
}
function logoutRequest() {
const logoutData = JSON.stringify({
pageURL: "LogoutProcess",
});
const url = "/controller/withDataPageRoute.php?data=" + logoutData;
HttpRequest(url);
}
//httpRequest로 데이터 보내기 (withDataPageRouting.php에만 적용)
function HttpRequest(url){
request = new XMLHttpRequest();
request.open("GET", url, true);
request.setRequestHeader("Content-type", "application/json");
request.send(); //$_GET['data']
//get response
request.onreadystatechange = function() {
if(request.readyState===XMLHttpRequest.DONE){
console.log(request.response);
if(request.response === "true") {
window.location.href = "../index.html";
}
else{
alert("로그아웃에 실패했습니다. 다시 시도해주세요.");
}
}
}
}
</script>
<body>
<div class="header">
<a href="/index.html">
<img class="header_home_btn_img" src="/lib/img/home_btn.png"/>
</a>
</div>
<div class="content">
<h1> Hello world! </h1>
<!-- 로그인 -->
<div id="loginDIV">
<form action="/controller/rendingPageRoute.php" method="GET">
<input type="hidden" name="pageURL" value="loginMain"/>
<input type="hidden" name="returnPageURL" value="loginMain.html"/>
<button> 로그인 </button>
</form>
</div>
<!-- 로그아웃 -->
<div id="logoutDIV" style="display:none">
<p id="userIDinfo"> </p>
<form>
<button type="button" onclick="logoutRequest()"> 로그아웃 </button>
</form>
</div>
<br>
<!-- 회원가입 -->
<form action="/controller/rendingPageRoute.php" method="GET">
<input type="hidden" name="pageURL" value="signupMain"/>
<input type="hidden" name="returnPageURL" value="signupMain.html"/>
<button> 회원가입 </button>
</form>
<br>
<!-- 강의 추천 -->
<form action="/controller/rendingPageRoute.php" method="GET">
<input type="hidden" name="pageURL" value="inputForAnalysis"/>
<input type="hidden" name="returnPageURL" value="inputForAnalysis.html"/>
<button> 강의 추천받으러 가기! </button>
</form>
<br>
<!-- 강의 별 게시판 -->
<form action="/controller/rendingPageRoute.php" method="GET">
<input type="hidden" name="pageURL" value="classGalleryMain"/>
<input type="hidden" name="returnPageURL" value="classGalleryMain.html"/>
<button> 강의 게시판 </button>
</form>
</div>
<div class="footer">
<img class="footer_logo_img" src="/lib/img/logo.png"/>
<p> Footer: 대충 아무내용 때려 넣기 </p>
</div>
</body>
</html>