--- config/db.config.php
+++ config/db.config.php
... | ... | @@ -8,10 +8,9 @@ |
8 | 8 |
$mysqli = new mysqli($host, $user, $pw, $dbname); |
9 | 9 |
|
10 | 10 |
if ($mysqli->connect_error) { // DB 접속 실패 |
11 |
- $connStatus = "MySQL 접속실패"; |
|
11 |
+ $connStatus = "MySQL Connection Failed"; |
|
12 | 12 |
die('Connection failed : ' . $mysqli->connect_error); |
13 | 13 |
|
14 | 14 |
}else{ // DB 접속 성공 |
15 |
- $connStatus = "MySQL 접속성공"; |
|
16 |
-} |
|
17 |
-?> |
|
15 |
+ $connStatus = "MySQL Connection Successfully"; |
|
16 |
+}(No newline at end of file) |
+++ config/logout.php
... | ... | @@ -0,0 +1,4 @@ |
1 | +<?php | |
2 | +session_start(); | |
3 | +session_destroy(); | |
4 | +header('Location:../index.php');(No newline at end of file) |
--- config/signIn.php
+++ config/signIn.php
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 |
/** |
3 | 3 |
* @var $mysqli |
4 | 4 |
*/ |
5 |
+ session_start(); |
|
5 | 6 |
ini_set("display_errors", "0"); |
6 | 7 |
include("db.config.php"); |
7 | 8 |
|
... | ... | @@ -16,6 +17,8 @@ |
16 | 17 |
if($id != null && $pw != null){ |
17 | 18 |
if($data[0] == $id){ |
18 | 19 |
if($data[1] == $pw){ |
20 |
+ $_SESSION['is_login']=true; |
|
21 |
+ $_SESSION['id']=$id; |
|
19 | 22 |
echo "<script>alert('로그인 성공');</script>"; |
20 | 23 |
echo "<meta http-equiv='refresh' content='0.1; url=../main.php'>"; |
21 | 24 |
}else{ |
--- index.php
+++ index.php
... | ... | @@ -7,6 +7,12 @@ |
7 | 7 |
?> |
8 | 8 |
<!doctype html> |
9 | 9 |
<html lang="ko"> |
10 |
+<?php |
|
11 |
+ session_start(); |
|
12 |
+ if (isset($_SESSION['is_login'])){ |
|
13 |
+ header('Location:main.php'); |
|
14 |
+ } |
|
15 |
+?> |
|
10 | 16 |
<head> |
11 | 17 |
<meta charset="UTF-8"> |
12 | 18 |
<meta name="viewport" |
--- main.php
+++ main.php
... | ... | @@ -15,8 +15,10 @@ |
15 | 15 |
*/ |
16 | 16 |
ini_set("display_errors", 1); |
17 | 17 |
include("config/select.php"); |
18 |
-if(!preg_match("/".$_SERVER['HTTP_HOST']."/i",$_SERVER['HTTP_REFERER'])){ |
|
19 |
- exit('Access Deny!!'); |
|
18 |
+session_start(); |
|
19 |
+if (!isset($_SESSION['is_login'])){ |
|
20 |
+ echo "<script>alert('Need Login')</script>"; |
|
21 |
+ header('Location:index.php'); |
|
20 | 22 |
} |
21 | 23 |
?> |
22 | 24 |
<!doctype html> |
... | ... | @@ -63,7 +65,7 @@ |
63 | 65 |
<div id="page"> |
64 | 66 |
<div id="title" title="Refresh"><h1><a href="main.php" id="refresh">Notice Board</a></h1></div> |
65 | 67 |
<div id="logoutSector"> |
66 |
- <button id="btnLogout" onclick="location.href='index.php'">Logout</button> |
|
68 |
+ <button id="btnLogout" onclick="location.href='config/logout.php'">Logout</button> |
|
67 | 69 |
</div> |
68 | 70 |
<hr id="hr"> |
69 | 71 |
<div id="contents"> |
--- updateWrite.php
+++ updateWrite.php
... | ... | @@ -5,8 +5,9 @@ |
5 | 5 |
*/ |
6 | 6 |
ini_set("display_errors", 0); |
7 | 7 |
include("config/clickedSelect.php"); |
8 |
-if(!preg_match("/".$_SERVER['HTTP_HOST']."/i",$_SERVER['HTTP_REFERER'])){ |
|
9 |
- exit('Access Deny!!'); |
|
8 |
+session_start(); |
|
9 |
+if (!isset($_SESSION['is_login'])){ |
|
10 |
+ header('Location:index.php'); |
|
10 | 11 |
} |
11 | 12 |
?> |
12 | 13 |
<!doctype html> |
--- view.php
+++ view.php
... | ... | @@ -11,8 +11,9 @@ |
11 | 11 |
ini_set("display_errors", 0); |
12 | 12 |
include("config/clickedSelect.php"); |
13 | 13 |
include("config/replySelect.php"); |
14 |
-if(!preg_match("/".$_SERVER['HTTP_HOST']."/i",$_SERVER['HTTP_REFERER'])){ |
|
15 |
- exit('Access Deny!!'); |
|
14 |
+session_start(); |
|
15 |
+if (!isset($_SESSION['is_login'])){ |
|
16 |
+ header('Location:index.php'); |
|
16 | 17 |
} |
17 | 18 |
?> |
18 | 19 |
<!doctype html> |
--- write.php
+++ write.php
... | ... | @@ -3,8 +3,9 @@ |
3 | 3 |
* @var $connStatus |
4 | 4 |
*/ |
5 | 5 |
include("config/db.config.php"); |
6 |
-if(!preg_match("/".$_SERVER['HTTP_HOST']."/i",$_SERVER['HTTP_REFERER'])){ |
|
7 |
- exit('Access Deny!!'); |
|
6 |
+session_start(); |
|
7 |
+if (!isset($_SESSION['is_login'])){ |
|
8 |
+ header('Location:index.php'); |
|
8 | 9 |
} |
9 | 10 |
?> |
10 | 11 |
<!doctype html> |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?