Windows NT P3613 10.0 build 20348 (Windows Server 2022) AMD64
C:
/
Inetpub
/
vhosts
/
gyandeepclasses.com
/
pdpandyamcc.com
/
admin
/
C:/Inetpub/vhosts/gyandeepclasses.com/pdpandyamcc.com/admin/infraimagesupdate.php
<?php include_once('header.php'); ?> <!-- partial --> <div class="main-panel"> <?php if ($_SERVER['REQUEST_METHOD'] == "POST") { // Collect all form data $infraimageid = strip_tags( $_POST['id']); $infraid = strip_tags( $_POST['infraid']); $stmt = $conn->prepare("UPDATE infraimages SET infraid=? WHERE id=?"); $stmt->bind_param("ss", $infraid, $infraimageid); $stmt->execute(); if(!empty($_FILES['image']['name'])){ $target_dir = "../infraimages/"; $imageFileType = strtolower(pathinfo($_FILES['image']['name'],PATHINFO_EXTENSION)); $target_file = "../infraimages/" . "II_".$infraimageid.".". $imageFileType; move_uploaded_file($_FILES["image"]["tmp_name"], $target_file); $target_file = "II_".$infraimageid.".". $imageFileType; $stmt = $conn->prepare("update infraimages set image=? where id =?"); $stmt->bind_param("ss", $target_file,$infraimageid); // print_r($stmt); if ($stmt->execute()) { echo "<script>alert('Infra Image updated successfully.'); window.location.href='infraimageslist.php';</script>"; exit(); } else { echo "<script>alert('Update failed. Please try again.');</script>"; } } echo "<script>alert('Infra Image updated successfully.'); window.location.href='infraimageslist.php';</script>"; } else $infraimageid = $_GET['id']; // Fetch the current data for the given Event_image_id $data = $conn->query("SELECT * FROM infraimages WHERE id='$infraimageid'"); $row = $data->fetch_assoc(); if (!$row) { die("No record found for Event_image_id: $eventimageid"); } // Fetch available event IDs for dropdown $events = $conn->query("SELECT * FROM infra"); ?> <div class="content-wrapper"> <div class="row"> <div class="col-lg-12 grid-margin stretch-card"> <div class="card"> <div class="card-body"> <h4 class="card-title" style="font-size:30px">Update Image Details</h4> <div class="table-responsive"> <div class="card"> <div class="content"> <form class="forms-sample" method="post" autocomplete="off" enctype="multipart/form-data"> <br> <div class="col-md-10"> <div class="form-group"> <label>Infra ID</label> <select class="form-control" id="infraid" name="infraid" required> <option value="" selected>Select an Infra</option> <?php while ($row1 = $events->fetch_assoc()){ ?> <option value="<?php echo htmlspecialchars($row1['id']); ?>" <?php if($row1['id']==$row['infraid']) echo "selected";?>> <?php echo htmlspecialchars($row1['title']); ?> </option> <?php } ?> </select> </div> <div class="form-group"> <label> Image URL</label> <img src="../infraimages/<?php echo htmlspecialchars($row['image']); ?>" height="100px"> <input type="file" class="form-control" id="image" name="image" value="<?php echo htmlspecialchars($row['image']); ?>" placeholder="Main Image URL"> </div> <input type="hidden" name="id" value="<?php echo htmlspecialchars($row['id']); ?>"> </div> <div class="clearfix"></div> <div class="card-footer"> <button type="submit" class="btn btn-primary mr-2">Update Image</button> </div> </form> </div> </div> </div> </div> </div> </div> </div> </div> <?php include_once('footer.php'); ?>