forked from WebH3ll/kyohyun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrite.php
executable file
·114 lines (91 loc) · 3.57 KB
/
write.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Write</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<link href="css/navbar.css" rel="stylesheet" />
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>
<?php
include "./script/navbar.php";
include "./script/dbconnect.php";
ini_set('display_errors', '0');
if (isset($_GET['Idx'])) {
$idx = $_GET['Idx'];
$query = "SELECT * FROM memo WHERE Idx='$idx'";
$result = $db->query($query)->fetchArray();
}
?>
<div style="width:800px; float:center; margin:0 auto;" class="border">
<form action="writePost.php" method="POST" onsubmit="return chkFrm();">
<input type="hidden" name="Idx" value="<? if (isset($idx)) { echo $idx; }?>">
<table border="1" class="table w-auto">
<tr>
<th style="width:200px;"> ID </th>
<td style="width:600px;"> <?=$_SESSION['isLoginId']?> </td>
</tr>
<tr>
<th> Title </th>
<td> <input type="text" name="Title" id="Title" style="width:100%" value="<? if (isset($result)) {echo $result['Title'];}?>"> </td>
</tr>
<tr>
<th> Memo </th>
<td>
<textarea name="Memo" id="Memo" style="width:100%; height:300px;"><? if (isset($result)) {echo $result['Memo'];}?></textarea>
</td>
</tr>
</tr>
<th> Is Secret? </th>
<td> <input type="checkbox" name="IsSecret" id="IsSecret" value="0" onclick="IsChecked();" unchecked> </td>
</tr>
<tr id="Password">
</tr>
<tr>
<td colspan="2">
<div style="text-align:center;">
<input type="submit" class="btn btn-warning" value="Save">
</div>
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
<script>
// 빈 공간 체크
function chkFrm() {
var title = document.getElementById("Title").value;
var memo = document.getElementById("Memo").value;
var isSecret = document.getElementById("IsSecret").value;
if (title == "") {
alert("Please enter title");
document.getElementById("Title").focus();
return false;
}
else if (memo == "") {
alert("Please enter memo");
document.getElementById("Memo").focus();
return false;
}
return true;
}
function IsChecked() {
var checkbox = document.getElementById("IsSecret");
if (checkbox.checked == 1) {
document.getElementById("IsSecret").value = 1;
document.getElementById("Password").innerHTML = "<th> Password </th>"+"<td> <input type='Password' name='MemoPassword' placeholder='Password' size='20'> </td>";
}
else {
document.getElementById("IsSecret").value = 0;
document.getElementById("Password").innerHTML = "";
}
}
</script>
<?php
$db->close();
?>