MMCT TEAM
Server IP : 103.53.40.154  /  Your IP : 3.141.29.90
Web Server : Apache
System : Linux md-in-35.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : ppcad7no ( 715)
PHP Version : 8.2.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home2/ppcad7no/bhatiataxiservice.in/../leetcoaching.co.in/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/ppcad7no/bhatiataxiservice.in/../leetcoaching.co.in/admin/edit-photo.php
<?php
// Include config file for database connection
include_once('config.php');

// Handle form submission
if (isset($_POST['update'])) {
    $id = $_POST['id'];
    $img_title = $_POST['img_title'];
    $show_btn = $_POST['show_btn'];

    // Use prepared statements to prevent SQL injection
    $stmt = $db->prepare("UPDATE tbl_image SET img_title = ?, show_btn = ? WHERE p_id = ?");
    $stmt->bind_param("ssi", $img_title, $show_btn, $id);

    if ($stmt->execute()) {
        echo ("<script>
                window.alert('Successfully Updated');
                window.location.href='photo_gallery.php';
              </script>");
        $stmt->close();
        $db->close();
    } else {
        echo "Error: " . $stmt->error;
    }
}

if (isset($uploaded_files)) {
    foreach ($uploaded_files as $file) {
        if (file_exists($file)) {
            unlink($file);
        }
    }
}
?>

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

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Admin</title>
    <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
    <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
    <link href="css/sb-admin-2.min.css" rel="stylesheet">
    <link href="vendor/datatables/dataTables.bootstrap4.min.css" rel="stylesheet">
    <style>
        div.dataTables_wrapper div.dataTables_filter input {
            box-shadow: 0px 0 0 !important;
            transform: translate(-123px, 1px);
        }
    </style>
</head>

<body id="page-top">
    <div id="wrapper">
        <?php include_once('sidebar.php') ?>
        <div id="content-wrapper" class="d-flex flex-column">
            <div id="content">
                <?php include_once('topbar.php') ?>
                <div class="container-fluid">
                    <div class="d-sm-flex align-items-center justify-content-between mb-4">
                        <h1 class="h3 mb-0 text-gray-800">Edit Category</h1>
                    </div>
                    <div class="card shadow mb-4">
                        <div class="card-body">
                            <div class="container-fluid">
                                <?php
                                if (isset($_GET['id'])) {
                                    $id = $_GET['id'];
                                    $query = "SELECT * FROM tbl_image WHERE p_id = ?";
                                    $stmt = $db->prepare($query);
                                    $stmt->bind_param("i", $id);
                                    $stmt->execute();
                                    $result = $stmt->get_result();

                                    if ($result->num_rows > 0) {
                                        $data = $result->fetch_assoc();
                                ?>
                                <form action="" method="POST">
                                    <div class="row">
                                        <div class="col">
                                            <input type="hidden" value="<?php echo $data['p_id']; ?>" name="id">
                                            <div class="form-group">
                                                <label>Title Name</label>
                                                <input type="text" class="form-control" name="img_title" value="<?php echo $data['img_title']; ?>" required>
                                            </div>
                                        </div>
                                        <div class="col">
                                            <label>This Image Show On Home Page</label>
                                            <select class="form-control" name="show_btn" required>
                                                <option value="Yes" <?php if ($data['show_btn'] == 'Yes') echo 'selected'; ?>>Yes</option>
                                                <option value="No" <?php if ($data['show_btn'] == 'No') echo 'selected'; ?>>No</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-12">
                                            <button type="submit" name="update" class="btn btn-success">Update</button>
                                        </div>
                                    </div>
                                </form>
                                <?php
                                    } else {
                                        echo "No record found.";
                                    }
                                    $stmt->close();
                                } else {
                                    echo "Invalid request.";
                                }
                                ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <?php include_once('footer.php') ?>
            <script src="ckeditor/ckeditor.js"></script>
        </div>
    </div>
</body>

</html>

MMCT - 2023