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/eventimagesupdate.php
<?php include_once('header.php'); ?> <!-- partial --> <div class="main-panel"> <?php if ($_SERVER['REQUEST_METHOD'] == "POST") { // Collect all form data $eventimageid = strip_tags( $_POST['Event_image_id']); $eventid = strip_tags( $_POST['Event_id']); $stmt = $conn->prepare("UPDATE eventimages SET Event_id=? WHERE Event_image_id=?"); $stmt->bind_param("ss", $eventid, $eventimageid); $stmt->execute(); if(!empty($_FILES['image']['name'])){ $target_dir = "../eventimages/"; $imageFileType = strtolower(pathinfo($_FILES['image']['name'],PATHINFO_EXTENSION)); $target_file = "../eventimages/" . "E_".$eventimageid.".". $imageFileType; move_uploaded_file($_FILES["image"]["tmp_name"], $target_file); $target_file = "E_".$eventimageid.".". $imageFileType; $stmt = $conn->prepare("update eventIMAGES set Imagepath=? where Event_image_id =?"); $stmt->bind_param("ss", $target_file,$eventimageid); // print_r($stmt); if ($stmt->execute()) { echo "<script>alert('Event Image updated successfully.'); window.location.href='eventimageslist.php';</script>"; exit(); } else { echo "<script>alert('Update failed. Please try again.');</script>"; } } echo "<script>alert('Event Image updated successfully.'); window.location.href='eventimageslist.php';</script>"; } else $eventimageid = $_GET['id']; // Fetch the current data for the given Event_image_id $data = $conn->query("SELECT * FROM eventimages WHERE Event_image_id='$eventimageid'"); $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 EventTitle, Event_id FROM events"); ?> <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>Event ID</label> <select class="form-control" id="Event_id" name="Event_id" required> <option value="">Select Event ID</option> <?php while ($event = $events->fetch_assoc()) { ?> <option value="<?php echo $event['Event_id']; ?>" <?php if ($event['Event_id'] == $row['Event_id']) echo 'selected'; ?>> <?php echo $event['EventTitle']; ?> </option> <?php } ?> </select> </div> <div class="form-group"> <label> Image path</label> <img src="../eventimages/<?php echo htmlspecialchars($row['Imagepath']); ?>" height="100px"> <input type="file" class="form-control" id="image" name="image" value="<?php echo htmlspecialchars($row['Imagepath']); ?>" placeholder="Main Image URL"> </div> <input type="hidden" name="Event_image_id" value="<?php echo htmlspecialchars($row['Event_image_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'); ?>