Viewing file: manage-comment.php (4.97 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
error_reporting(0);
include 'conn.php';
require_once "auth.php";
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title><?php include('title.php') ?></title>
<link rel="shortcut icon" type="image/png" href="images/fav.png">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/themify-icons.css">
<link rel="stylesheet" href="css/animate.css">
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/red.css" id="style_theme">
<link rel="stylesheet" href="css/responsive.css">
<link rel="stylesheet" href="charts/css/morris.css">
<link rel="stylesheet" href="css/jquery-jvectormap.css">
<link rel="stylesheet" href="datatable/dataTables.bootstrap4.min.css">
<link rel="stylesheet" href="plugins/summernote/summernote-bs4.css">
<script src="js/modernizr.min.js"></script>
<link rel="stylesheet" href="dist/css/user_css.css">
</head>
<body>
<!-- Pre Loader -->
<div class="loading">
<div class="spinner">
<div class="double-bounce1"></div>
<div class="double-bounce2"></div>
</div>
</div>
<!--/Pre Loader -->
<div class="wrapper">
<!-- Sidebar -->
<?php include('sidebar.php') ?>
<!-- /Sidebar -->
<!-- Page Content -->
<div id="content">
<div>
<?php include('topbar.php') ?>
</div>
<?php
include('conn.php'); // include the database connection file
$com = mysqli_query($con,"SELECT * FROM comments");
if (!$result) {
die("Query failed: " . mysqli_error($con));
}
if(isset($_POST['edit_comment'])) {
$comment_id = $_POST['id'];
$new_comment = $_POST['new_comment'];
$query = "UPDATE comments SET comment='$new_comment' WHERE id='$comment_id'";
mysqli_query($con, $query);
echo "<script>alert('Comment Updated Successfully');</script>
<script>window.location.href = 'manage-comment.php'</script>";
}
if(isset($_POST['delete_comment'])) {
$comment_id = $_POST['id'];
$query = "DELETE FROM comments WHERE id='$comment_id'";
mysqli_query($con, $query);
echo "<script>alert('Comment Deleted Successfully');</script>
<script>window.location.href = 'manage-comment.php'</script>";
}
?>
<div class="row no-margin-padding">
<div class="col-md-6">
<h3 class="block-title">Comments/مدیریت نظرات</h3>
</div>
<div class="col-md-6">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="index.html">
<span class="ti-home"></span>
</a>
</li>
<li class="breadcrumb-item">Comments</li>
</ol>
</div>
</div>
<div class="card card-outline card-info">
<table class="table table-bordered table-striped">
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Comment</th>
</tr>
<?php
while($comment=mysqli_fetch_array($com)){
?>
<tr>
<td></td>
<td><?php echo $comment['id'] ?></td>
<td><?php echo $comment['name'] ?></td>
<td><?php echo $comment['email'] ?></td>
<td><?php echo $comment['comment'] ?></td>
<td>
</td>
<td>
<!-- Form for editing a comment -->
<form method="post" action="">
<input type="hidden" name="id" value="<?php echo $comment['id']; ?>">
<textarea name="new_comment"><?php echo $comment['comment']; ?></textarea>
<button class="edit-user-btn" type="submit" name="edit_comment">Save Changes</button>
</form>
</td>
<td>
<form method="post">
<input type="hidden" name="id" value="<?php echo $comment['id']; ?>">
<button class="delete-user-btn" type="submit" name="delete_comment">Delete Comment</button>
</form>
</td>
</tr>
<?php } ?>
</table>
</div>
<!-- /Main Content -->
</div>
<!-- /Page Content -->
</div>
<!-- Back to Top -->
<a id="back-to-top" href="#" class="back-to-top">
<span class="ti-angle-up"></span>
</a>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="datatable/jquery.dataTables.min.js"></script>
<script src="datatable/dataTables.bootstrap4.min.js"></script>
<script src="js/custom.js"></script>
<script src="js/custom-datatables.js"></script>
<script src="plugins/jquery/jquery.min.js"></script>
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="dist/js/adminlte.min.js"></script>
<script src="plugins/summernote/summernote-bs4.min.js"></script>
<script>
$(function () {
$('.textarea').summernote()
})
</script>
</body>
</html>
|