Skip to content
This repository was archived by the owner on Mar 30, 2024. It is now read-only.

Commit

Permalink
hapus komentar
Browse files Browse the repository at this point in the history
  • Loading branch information
ftiannisa committed Jun 17, 2023
1 parent a84785f commit 3b812d9
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions komentar/delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
require_once '../templates/config/db_connection.php';

if (!isset($_SESSION['name'])) {
header("Location: index.php");
}

$id_komentar = (int)$_GET['id_komentar'];

// check if id_artikel is exist
$query = "SELECT * FROM t_komentar WHERE id_komentar=?";
$stmt = $connection->prepare($query);
$stmt->bind_param("i", $id_komentar);
$stmt->execute();
$result = $stmt->get_result();

if ($result->num_rows > 0) {
// delete data
echo "<script>alert('KOMENTAR BERHASIL DIHAPUS')</script>";
$query = "DELETE FROM t_komentar WHERE id_komentar=?";
$stmt = $connection->prepare($query);
$stmt->bind_param("i", $id_komentar);
$stmt->execute();
header("Location: ../dashboard.php?menu=menu_komentar");
} else {
echo "<script>alert('GAGAL MENGHAPUS KOMENTAR')</script>";
}

?>

0 comments on commit 3b812d9

Please sign in to comment.