PHP 8.5.2
Preview: edit-review.php Size: 5.88 KB
/home/serveshikshafoundation/htdocs/serveshikshafoundation.org.in/admin/html/edit-review.php

<?php
include('auth.php'); // Ensure authentication
include('connection.php'); // Database connection

// Initialize variables
$client_name = $client_location = $client_rating = $client_review = "";
$updateSuccess = false;

// Check if 'id' is provided in the URL
if (isset($_GET['id'])) {
    $review_id = intval($_GET['id']); // Sanitize input

    // Fetch review details
    $sql = "SELECT * FROM client_reviews WHERE id = $review_id";
    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
        $row = $result->fetch_assoc();
        $client_name = $row['client_name'];
        $client_location = $row['client_location'];
        $client_rating = $row['client_rating'];
        $client_review = $row['client_review'];
    } else {
        echo "<script>
                alert('Review not found!');
                window.location.href = 'testimonial.php';
              </script>";
        exit;
    }
}

// Handle form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $client_name = $conn->real_escape_string($_POST['clientName']);
    $client_location = $conn->real_escape_string($_POST['clientLocation']);
    $client_rating = intval($_POST['clientRating']);
    $client_review = $conn->real_escape_string($_POST['clientReview']);

    // Update query
    $update_sql = "UPDATE client_reviews SET 
                   client_name = '$client_name', 
                   client_location = '$client_location', 
                   client_rating = '$client_rating', 
                   client_review = '$client_review' 
                   WHERE id = $review_id";

    if ($conn->query($update_sql) === TRUE) {
        $updateSuccess = true;
    }
}
?>

<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Edit Review</title>
    <link rel="stylesheet" href="../assets/css/styles.min.css" />
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script> <!-- SweetAlert CDN -->
</head>

<body>
    <div class="page-wrapper" id="main-wrapper" data-layout="vertical" data-navbarbg="skin6" data-sidebartype="full"
        data-sidebar-position="fixed" data-header-position="fixed">

        <!-- Sidebar -->
        <?php include('aside.php') ?>

        <!-- Main Content -->
        <div class="body-wrapper">

            <!-- Header -->
            <?php include('header.php') ?>

            <div class="container mt-4">
                <h1>Edit Review</h1>
                <form action="" method="post">
                    <div class="form-group">
                        <label for="clientName">Name:</label>
                        <input type="text" id="clientName" name="clientName" class="form-control"
                            value="<?php echo $client_name; ?>" required>
                    </div>

                    <div class="form-group">
                        <label for="clientLocation">Location:</label>
                        <input type="text" id="clientLocation" name="clientLocation" class="form-control"
                            value="<?php echo $client_location; ?>" required>
                    </div>

                    <div class="form-group">
                        <label for="clientRating">Rating:</label>
                        <select id="clientRating" name="clientRating" class="form-control" required>
                            <option value="5" <?php if ($client_rating == 5) echo 'selected'; ?>>★★★★★</option>
                            <option value="4" <?php if ($client_rating == 4) echo 'selected'; ?>>★★★★☆</option>
                            <option value="3" <?php if ($client_rating == 3) echo 'selected'; ?>>★★★☆☆</option>
                            <option value="2" <?php if ($client_rating == 2) echo 'selected'; ?>>★★☆☆☆</option>
                            <option value="1" <?php if ($client_rating == 1) echo 'selected'; ?>>★☆☆☆☆</option>
                        </select>
                    </div>

                    <div class="form-group">
                        <label for="clientReview">Review:</label>
                        <textarea id="clientReview" name="clientReview" class="form-control" rows="4"
                            required><?php echo $client_review; ?></textarea>
                    </div>

                    <button type="submit" class="btn btn-primary mt-2">Update Review</button>
                    <a href="testimonial.php" class="btn btn-secondary mt-2">Cancel</a>

                    <!-- Hidden Input to Track Update Success -->
                    <input type="hidden" id="updateSuccess" value="<?php echo $updateSuccess ? 'true' : 'false'; ?>">
                </form>
            </div>
        </div>

        <script src="../assets/libs/jquery/dist/jquery.min.js"></script>
        <script src="../assets/libs/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
        <script src="../assets/js/sidebarmenu.js"></script>
        <script src="../assets/js/app.min.js"></script>
        <script src="../assets/libs/simplebar/dist/simplebar.js"></script>

        <!-- SweetAlert Script -->
        <script>
            document.addEventListener("DOMContentLoaded", function() {
                let updateSuccess = document.getElementById("updateSuccess").value;
                if (updateSuccess === "true") {
                    Swal.fire({
                        title: 'Success!',
                        text: 'Review updated successfully!',
                        icon: 'success',
                        showConfirmButton: false,
                        timer: 2500
                    }).then(() => {
                        window.location.href = 'add-testimonial.php';
                    });
                }
            });
        </script>

</body>

</html>

Directory Contents

Dirs: 11 × Files: 30

Name Size Perms Modified Actions
- drwxr-xr-x 2025-04-05 16:58:42
Edit Download
assets DIR
- drwxr-xr-x 2025-04-05 16:58:42
Edit Download
baby-dec DIR
- drwxr-xr-x 2025-04-05 16:58:42
Edit Download
- drwxr-xr-x 2025-04-05 16:58:42
Edit Download
- drwxr-xr-x 2025-04-05 16:58:44
Edit Download
- drwxr-xr-x 2025-04-05 16:58:44
Edit Download
- drwxr-xr-x 2025-04-05 16:58:44
Edit Download
- drwxr-xr-x 2025-04-05 16:58:44
Edit Download
- drwxr-xr-x 2025-04-05 16:58:44
Edit Download
- drwxr-xr-x 2025-04-05 16:58:46
Edit Download
- drwxr-xr-x 2025-04-05 16:58:46
Edit Download
8.63 KB lrw-r----- 2025-04-06 01:10:32
Edit Download
8.49 KB lrw-r----- 2025-04-05 20:17:06
Edit Download
8.33 KB lrw-r----- 2025-04-01 18:04:14
Edit Download
4.67 KB lrw-r----- 2025-07-01 06:02:29
Edit Download
6.91 KB lrw-r----- 2025-04-07 09:05:32
Edit Download
4.59 KB lrw-r----- 2025-07-01 06:36:30
Edit Download
164 B lrw-r----- 2025-04-05 17:07:44
Edit Download
471 B lrw-r----- 2026-04-07 07:13:01
Edit Download
4.07 KB lrw-r----- 2025-04-07 18:20:40
Edit Download
1.62 KB lrw-r----- 2025-03-31 20:18:28
Edit Download
1.92 KB lrw-r----- 2025-04-01 00:02:56
Edit Download
1.93 KB lrw-r----- 2025-04-01 18:10:28
Edit Download
1.20 KB lrw-r----- 2025-04-02 21:38:00
Edit Download
1.94 KB lrw-r----- 2025-04-06 00:58:20
Edit Download
1.62 KB lrw-r----- 2025-07-01 06:05:36
Edit Download
1.67 KB lrw-r----- 2025-03-31 21:50:12
Edit Download
3.15 KB lrw-r----- 2025-04-02 22:26:14
Edit Download
5.43 KB lrw-r----- 2025-04-22 13:05:58
Edit Download
6.16 KB lrw-r----- 2025-04-05 20:16:08
Edit Download
6.18 KB lrw-r----- 2025-04-02 20:43:44
Edit Download
5.88 KB lrw-r----- 2025-04-02 21:46:38
Edit Download
3.17 KB lrw-r----- 2025-07-01 06:17:56
Edit Download
4.14 KB lrw-r----- 2025-03-31 22:30:04
Edit Download
551.14 KB lrw-r--r-- 2025-03-29 19:52:38
Edit Download
3.14 KB lrw-r----- 2025-06-28 23:18:18
Edit Download
4.67 KB lrw-r----- 2025-04-02 22:16:18
Edit Download
7.83 KB lrw-r----- 2025-04-05 23:49:56
Edit Download
3.15 KB lrw-r----- 2025-04-07 18:21:46
Edit Download
120 B lrw-r----- 2024-07-06 23:58:34
Edit Download
5.12 KB lrw-r----- 2025-03-31 22:33:26
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).