-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_board_delete_news.php
56 lines (45 loc) · 1.36 KB
/
admin_board_delete_news.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
<?php
session_start();
if (isset($_SESSION["userlevel"])) $userlevel = $_SESSION["userlevel"];
else $userlevel = "";
if ( $userlevel != 1 )
{
echo("
<script>
alert('관리자가 아닙니다! 회원 삭제는 관리자만 가능합니다!');
history.go(-1)
</script>
");
exit;
}
if (isset($_POST["item"]))
$num_item = count($_POST["item"]);
else
echo("
<script>
alert('삭제할 게시글을 선택해주세요!');
history.go(-1)
</script>
");
$con = mysqli_connect("localhost", "Steve", "Vrick2956!@", "Term");
for($i=0; $i<count($_POST["item"]); $i++){
$num = $_POST["item"][$i];
$sql = "select * from board_news where num = $num";
$result = mysqli_query($con, $sql);
$row = mysqli_fetch_array($result);
$copied_name = $row["file_copied"];
if ($copied_name)
{
$file_path = "./data/".$copied_name;
unlink($file_path);
}
$sql = "delete from board_news where num = $num";
mysqli_query($con, $sql);
}
mysqli_close($con);
echo "
<script>
location.href = 'admin.php';
</script>
";
?>