-
Notifications
You must be signed in to change notification settings - Fork 1
/
delete.php
43 lines (37 loc) · 983 Bytes
/
delete.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
<?php
//Connect MYSQL & get INFO using $number
$connect = mysqli_connect("localhost", "yoobi", "toor", "php_db") or die("connect fail");
$id = $_GET["id"];
$number = $_GET["number"];
$board_info = $_GET["board_info"];
$query = "select title, youtube_link, content, id, date, hit, star from ".$board_info." where number=$number";
$result = $connect->query($query);
$rows = mysqli_fetch_assoc($result);
$title = $rows['title'];
$content = $rows['content'];
$usrid = $rows['id'];
session_start();
$URL = "./".$board_info.".php";
//Check SESSION userid with number's userid
if($_SESSION['userid']==$usrid)
{
//Delete Post
$query = "delete from ".$board_info." WHERE number=$number";
$result = $connect->query($query);
?>
<script>
alert("<?php echo "The post successfully deleted."?>");
location.replace("<?php echo $URL?>");
</script>
<?php
}
else
{
?>
<script>
alert("Permission Denied.");
history.back();
</script>
<?php
}
?>