This repository was archived by the owner on Mar 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathedit_post.php
More file actions
40 lines (36 loc) · 1.36 KB
/
edit_post.php
File metadata and controls
40 lines (36 loc) · 1.36 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
<?php
// include "koneksi.php";
$connect = file_get_contents(".env");
$dbjson = json_decode($connect);
$koneksi = mysqli_connect($dbjson->host, $dbjson->username, $dbjson->password, $dbjson->db);
include "validate_token.php";
// $koneksi = mysqli_connect("localhost", "root", "", "small_blog");
$judul = $_POST['judul'];
$isi = $_POST['isi'];
$gambar = $_POST['gambar'];
$linking = $_POST['linking'];
$idPost = $_POST['idPost'];
$idKategori = $_POST['id_kategori'];
$isidb = mysqli_real_escape_string($koneksi, $_POST['isi']);
session_start();
$user = $_SESSION['username'];
$posting = mysqli_query($koneksi, "UPDATE post SET judul='$judul', isi = '$isidb', img='$gambar', id_kategori='$idKategori' where id_post=$idPost ");
$query = mysqli_query($koneksi, "SELECT * FROM admin a where a.username = '$user' ");
if($query && $_SESSION['status']=="login"){
$result = array("message"=>"Berhasil Mengubah Postingan", "success"=>true);
$posting;
$statusQuery = $posting;
if(!$statusQuery){
$rest = array("message"=>"Gagal", "success"=>false);
echo json_encode($rest);
}else {
header('Content-Type: application/json');
echo json_encode($result);
}
} else {
$errorSql = mysqli_error($koneksi);
$fail = array("success"=>false, "error"=>$errorSql);
header('Content-Type: application/json');
echo json_encode($fail);
}
?>