-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeletepost.php
43 lines (34 loc) · 1.01 KB
/
deletepost.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
$con = new mysqli('sql12.freemysqlhosting.net', 'sql12369803', '8fzQjG6qQj', 'sql12369803');
if($con->connect_errno > 0){
die('Unable to connect to database [' . $con->connect_error . ']');
}
?>
<?php
ob_start();
session_start();
if (!isset($_SESSION['user_login'])) {
header("location: index.php");
}
else {
$user = $_SESSION['user_login'];
$result = $con->query("SELECT * FROM user WHERE id='$user'");
$get_user_email = mysqli_fetch_assoc($result);
$uname_db = $get_user_email['fullname'];
$uemail_db = $get_user_email['email'];
}
if (isset($_REQUEST['pid'])) {
$pstid = mysqli_real_escape_string($con, $_REQUEST['pid']);
$result3 = $con->query("SELECT * FROM post WHERE id='$pstid'");
$get_user_pid = mysqli_fetch_assoc($result3);
$uid_db = $get_user_pid['postby_id'];
if($user != $uid_db){
header('location: post.php');
}else{
$result = $con->query("DELETE FROM post WHERE id='$pstid'");
header('location: profile.php?uid='.$user.'');
}
}else {
header('location: index.php');
}
?>