-
Notifications
You must be signed in to change notification settings - Fork 1
/
editPost.php
45 lines (38 loc) · 1.19 KB
/
editPost.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
<?php
include ("includes/db.class.php");
include ("includes/functions.php");
session_start();?>
<?php if ($_SESSION["role"]=="Admin" && "Moderator" && "Editor") :
$id=$_POST["id"];
$title = $_POST["title"];
$content = $_POST["content"];
$name=$_SESSION["username"];
$bla=$pdo->prepare("SELECT username, role FROM denemeusers WHERE username='$name'");
$bla->execute();
$result=$bla->fetchAll(PDO::FETCH_ASSOC);
if ($result) {
$res=$result[0]["role"];
if ($res=="User") {
echo "Bu işlemi yapma yetkiniz yoktur";
}
else {
$test = $pdo->prepare("UPDATE denemeposts SET title = '$title',body='$content' WHERE id= '$id'");
$test->execute();
if ($test)
{
echo "Güncelleme İşlemi Başarılı Bir Şekilde Gerçekleştirildi";?>
<br>
<a href="posts.php"> Gönderilerinize Geri Dönebilirsiniz</a><?php
}
else
{
echo "Hata";
}
}
}
else{
echo "Post not found! Check again..";
}
else:
echo "You can not access this page!";
endif;