Repository navigation
Expand file tree
/
Copy pathdeletePost.php
More file actions
74 lines (55 loc) · 2.01 KB
/
Copy pathdeletePost.php
File metadata and controls
74 lines (55 loc) · 2.01 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
<?php
header("Access-Control-Allow-Origin: *");
require_once('config.php');
$userName=$_POST['userName'];
$sql="SELECT * FROM users WHERE userName=?";
$stmt=mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt,$sql))
{
header('location: login.php?error=sqlerror');
exit();
}
else
{
mysqli_stmt_bind_param($stmt,"s",$userName);
mysqli_stmt_execute($stmt);
$result=mysqli_stmt_get_result($stmt);
if($row=mysqli_fetch_assoc($result))
{
$userName= $row['userName'];
$email=$row['email'];
$path=$row['profilePic'];
$amountBot=$row['amountBot'];
}
}
if($_POST['delete2']=="true")
{
$sql="SELECT * FROM posts WHERE id='".$_POST['id']."'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) == 0) {
exit();
}
else
{
$row = mysqli_fetch_assoc($result);
$amountA=$row['amountA'];
$amountB=$row['amountB'];
$sum=$amountA+$amountB;
}
$amountBot=$amountBot-$sum;
$sql="UPDATE users SET amountBot='".$amountBot."' WHERE userName='".$userName."'";
if ($conn->query($sql) == TRUE) {
} else {
}
$sql="UPDATE posts SET isDeleted=1 WHERE userName='".$userName."' AND id='".$_POST['id']."'";
if ($conn->query($sql) == TRUE) {
echo'
<script>
window.location="http://eavni93.com/app/myPosts.html";
</script>
';
} else {
echo "Error deleting record: " . $conn->error;
}
$conn->close();
}