-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwriting.php
More file actions
156 lines (141 loc) · 5.05 KB
/
writing.php
File metadata and controls
156 lines (141 loc) · 5.05 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
$title = $_POST["TITLE"];
$name = $_POST["NAME"];
$thema = $_POST["THEMA"];
$pw = $_POST["PW"];
$textarea = $_POST["TEXTCONTENT"];
$con = mysqli_connect("localhost", "jinhui0131", "tlswlsgml1", "jinhui0131");
$sqll = "SELECT* FROM QnABOARD";
$mresult = mysqli_query($con, $sqll);
$bnum = $_REQUEST["BOARDNUM"];
$chk = "none";
$n = 1;
while($roww = mysqli_fetch_array($mresult))
{
if($bnum == $n)
$chk = "inquire";
$n++;
}
if($chk == "inquire")
{
$sql1 = "SELECT* FROM QnABOARD WHERE BOARDNUM = '".$bnum."'";
$ret3 = mysqli_query($con, $sql1);
$row = mysqli_fetch_assoc($ret3);
$title = $row["TITLE"];
$name = $row["NAME"];
$thema = $row["THEMA"];
$textarea = $row["TEXTCONTENT"];
$pw = $row["PW"];
$msg = "조회 되었습니다.";
}
else if($chk == "none")
{
$query = "SELECT * FROM QnABOARD ORDER BY BOARDNUM DESC";
$result = mysqli_query($con,$query);
$data = mysqli_fetch_assoc($result);
$sql = "INSERT INTO QnABOARD VALUES
(null, '$title', '$name', null, '$pw', '$thema', '$textarea')";
$ret2 = mysqli_query($con, $sql);
$bnum = $data["BOARDNUM"]+1;
$msg = "등록 되었습니다.";
}
?>
<script>
alert("<?=$msg ?>");
function backpage(){
var result = confirm("목록으로 돌아가시겠습니까?");
if(result){
location.href = "q&a.php";
}
}
function deleteWriting(){
var result = confirm("게시물을 삭제하시겠습니까?");
if(result){
var pwchk = prompt("비밀번호를 입력해주세요.", "");
if(pwchk == "<?=$pw?>")
{
$.post("delete.php", {num : "<?=$bnum?>"}, function(result1){
alert(result1);
location.href = "q&a.php";
});
}
else
alert("비밀번호가 틀렸습니다.");
}
else
return false;
}
</script>
<?php
mysqli_close($con);
?>
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>웹프로젝트</title>
<link rel="stylesheet" href="css/writing2.css">
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
</head>
<body>
<div id="container">
<header>
<a href="main_display.html"><img id="logotype" src="images/main_logo.JPG" alt="메인로고"></a>
<ul>
<li><a href="reason.html">reason</a></li>
<li><a href="notice.html">notice</a></li>
<li><a href="rooms.html">rooms</a></li>
<li><a href="booking.html">booking</a></li>
<li><a href="check booking.html">check booking</a></li>
<li><a href="q&a.php">q&a</a></li>
</ul>
</header>
<section>
<h1>q&a</h1>
<form action="write.php" method="post" id="writed">
<table cellspacing="0">
<tr>
<th>제목</th>
<td id="title"><?php echo $title ?></td>
</tr>
<tr>
<th>작성자</th>
<td><?php echo $name ?></td>
</tr>
<tr>
<th>테마</th>
<td><?php echo $thema ?></td>
</tr>
<tr>
<td colspan="2" id="textareatype">
<?php echo $textarea ?>
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center;">
<input type="hidden" name="bn" value="<?php echo $bnum ?>">
<input type="hidden" name="ti" value="<?php echo $title ?>">
<input type="hidden" name="na" value="<?php echo $name ?>">
<input type="hidden" name="th" value="<?php echo $thema ?>">
<input type="hidden" name="ta" value="<?php echo $textarea ?>">
<input type="hidden" name="pw" value="<?php echo $pw ?>">
<input type="submit" value="수정하기" class="buttontype">
<input type="button" value="삭제하기" onclick="deleteWriting();" class="buttontype">
<input type="button" value="목록으로" onclick="backpage();" class="buttontype">
</td>
</tr>
</table>
</form>
</section>
<footer>
<ul>
<li>주소 : 공주대학교 천안공과대학 8층</li>
<li>대표 : 손원주</li>
<li>전화번호 : 010-5157-9214</li>
<li>이메일 : sonwonjoo@naver.com</li>
<li>Copyright ⓒ REASON All Right Reserved</li>
</ul>
</footer>
</div>
</body>
</html>