? 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/superadmin/
File Upload :
Current File : /home/u949514618/domains/drpktiwari.com/public_html/superadmin/centres.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['user_id'])) {
    // If not logged in, redirect to login page
    header("Location: login.php");
    exit();
}

// If logged in, proceed with the rest of the page
include_once('db.php');

?>
<!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>
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
    <script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></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'); ?>

          <?php

if (isset($_POST['add_centre'])) {
    $centre_name = $_POST['centre_name'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $address = $_POST['address'];
    $username = $_POST['username'];
    $password = password_hash($_POST['password'], PASSWORD_BCRYPT); // Encrypt password

    $stmt = $conn->prepare("INSERT INTO centre (centre_name, email, phone, address, username, password) VALUES (?, ?, ?, ?, ?, ?)");
    $stmt->bind_param("ssssss", $centre_name, $email, $phone, $address, $username, $password);

    if ($stmt->execute()) {
        echo "<script>Swal.fire('Success', 'Centre added successfully', 'success').then(() => { window.location.href='centres.php'; });</script>";
    } else {
        echo "<script>Swal.fire('Error', 'Failed to add centre', 'error');</script>";
    }

    $stmt->close();
}

// Update Data
if (isset($_POST['update_centre'])) {
    $id = $_POST['id'];
    $centre_name = $_POST['centre_name'];
    $phone = $_POST['phone'];

    $stmt = $conn->prepare("UPDATE centre SET centre_name=?, phone=? WHERE id=?");
    $stmt->bind_param("ssi", $centre_name, $phone, $id);

    if ($stmt->execute()) {
        echo "<script>Swal.fire('Updated!', 'Centre details updated successfully.', 'success').then(() => { window.location.href='centres.php'; });</script>";
    } else {
        echo "<script>Swal.fire('Error', 'Failed to update centre', 'error');</script>";
    }

    $stmt->close();
}

// Delete Data
if (isset($_GET['delete'])) {
    $id = $_GET['delete'];

    $stmt = $conn->prepare("DELETE FROM centre WHERE id=?");
    $stmt->bind_param("i", $id);

    if ($stmt->execute()) {
        echo "<script>Swal.fire('Deleted!', 'Centre has been deleted.', 'success').then(() => { window.location.href='centres.php'; });</script>";
    } else {
        echo "<script>Swal.fire('Error', 'Failed to delete centre', 'error');</script>";
    }

    $stmt->close();
}

// Fetch Data
$result = $conn->query("SELECT * FROM centre");
?>


          <!-- 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">User/Centre</span> Section</h4>
                <form action="centres.php" method="POST">
    <div class="mb-3">
        <label class="form-label">Centre Name</label>
        <input type="text" class="form-control" name="centre_name" placeholder="Enter Centre Name" required>
    </div>
    <div class="mb-3">
        <label class="form-label">Email ID</label>
        <input type="email" class="form-control" name="email" placeholder="Enter Email ID" required>
    </div>
    <div class="mb-3">
        <label class="form-label">Phone No</label>
        <input type="tel" class="form-control" name="phone" placeholder="Enter Phone Number" required>
    </div>
    <div class="mb-3">
        <label class="form-label">Address</label>
        <textarea class="form-control" name="address" rows="3" placeholder="Enter Address" required></textarea>
    </div>
    <div class="mb-3">
        <label class="form-label">Username</label>
        <input type="text" class="form-control" name="username" placeholder="Enter Username" required>
    </div>
    <div class="mb-3 position-relative">
        <label class="form-label">Password</label>
        <div class="input-group">
            <input type="password" class="form-control" id="password" name="password" placeholder="Enter Password" required>
            <span class="input-group-text" onclick="togglePassword()">
                <i class="fas fa-eye" id="eye-icon"></i>
            </span>
        </div>
    </div>
    <button type="submit" class="btn btn-primary" name="add_centre">Add Centre</button>
</form>


                    <hr>

                    <h4 class="mb-3">Centre List</h4>
                    <table class="table table-bordered">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>Centre Name</th>
                                <th>Phone</th>
                                <th>Actions</th>
                            </tr>
                        </thead>
                        <tbody>
            <?php while ($row = $result->fetch_assoc()): ?>
                <tr>
                    <td><?= $row['id'] ?></td>
                    <td><?= $row['centre_name'] ?></td>
                    <td><?= $row['phone'] ?></td>
                    <td>
                        <button class='btn btn-warning btn-sm edit-btn' 
                                data-id='<?= $row['id'] ?>' 
                                data-name='<?= $row['centre_name'] ?>' 
                                data-phone='<?= $row['phone'] ?>'>
                            Edit
                        </button>
                        <a href="?delete=<?= $row['id'] ?>" class="btn btn-danger btn-sm">Delete</a>
                    </td>
                </tr>
            <?php endwhile; ?>
        </tbody>
                    </table>
                </div>  

            </div>
            <!-- / Content -->
            <!-- Edit Modal -->
<div class="modal fade" id="editModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Edit Centre</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <div class="modal-body">
                <form method="POST">
                    <input type="hidden" name="id" id="edit-id">
                    <div class="mb-3">
                        <label>Centre Name</label>
                        <input type="text" class="form-control" name="centre_name" id="edit-name" required>
                    </div>
                    <div class="mb-3">
                        <label>Phone</label>
                        <input type="text" class="form-control" name="phone" id="edit-phone" required>
                    </div>
                    <button type="submit" class="btn btn-success" name="update_centre">Update</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>
                  <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>
    $(".edit-btn").click(function () {
        $("#edit-id").val($(this).data("id"));
        $("#edit-name").val($(this).data("name"));
        $("#edit-phone").val($(this).data("phone"));
        $("#editModal").modal("show");
    });

    function togglePassword() {
        var input = document.getElementById("password");
        input.type = input.type === "password" ? "text" : "password";
    }
</script>
                      
  </body>
</html>

T1KUS90T
  root-grov@89.117.188.241:~$