-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmodify.php
98 lines (94 loc) · 3.38 KB
/
modify.php
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="css/qna.css" />
<link rel="stylesheet" href="css/animate.css" />
<link rel="shortcut icon" href="img/favicon.png" />
<script src="js/wow.min.js"></script>
<script>
new WOW().init();
</script>
<title>SE LAB</title>
</head>
<body>
<div id="header">
<div id="navi">
<h1>
<a href="new.html"><img src="img/logo2.png" id="logo" /></a>
</h1>
<ul id="navi-center">
<li><a href="aboutme2-2.html">ABOUT</a></li>
<li><a href="members.html">MEMBERS</a></li>
<li><a href="publication.html">PUBLICATION</a></li>
<li><a href="courses.html">COURSE</a></li>
<li><a href="qna.php">Q&A</a></li>
</ul>
</div>
</div>
<div id="qna_content">
<div id="qna_text">
Q&A
</div>
<?php
$db = new PDO("mysql:dbname=qna;host:localhost", "lsm", "333");
$id = $_GET['id'];
$number = $_GET['number'];
$result = $db->query("SELECT title, content, date, id from board where post_number= $number");
session_start();
$URL = "./qna.php";
foreach ($result as $row) {
$title = $row['title'];
$content = $row['content'];
$usrid = $row['id'];
$isSame = strcmp($_SESSION['userid'], $usrid);
if (!isset($_SESSION['userid'])) { ?>
<script>
alert("권한이 없습니다.");
location.replace("<?php echo $URL ?>");
</script>
<?php } else if (!$isSame) { ?>
<div id="board">
<form method="POST" action="modify_action.php">
<table id="qna_table">
<thead>
<tr>
<td colspan="2">
Modify
</td>
</tr>
</thead>
<tbody>
<tr>
<td>Name</td>
<td><input type="hidden" name="id" value="<?= $_SESSION['userid'] ?>"><?= $_SESSION['userid'] ?></td>
</tr>
<tr>
<td>Title</td>
<td><input type=text name=title size=60 value="<?= $title ?>"></td>
</tr>
<tr>
<td>Content</td>
<td><textarea name=content cols=85 rows=15><?= $content ?></textarea></td>
</tr>
<input type="hidden" name="number" value="<?= $number ?>">
</td>
</tr>
</tbody>
</table>
<input class="table-button" type="submit" value="modify">
</form>
<?php } else { ?>
<script>
alert("권한이 없습니다.");
location.replace("<?php echo $URL ?>");
</script>
<?php }
} ?>
</div>
</div>
</body>
</html>