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/eventimagesadd.php
<?php include_once('../dbconfig.php'); $events_query = "SELECT Event_id, EventTitle FROM events"; $events_result = $conn->query($events_query); if ($_SERVER['REQUEST_METHOD'] == "POST") { // Collect all form data $event_id = strip_tags( $_POST['eventid']); $stmt = $conn->prepare("INSERT INTO eventimages (Event_id) VALUES (?)"); $stmt->bind_param("s", $event_id); $stmt->execute(); $last_id = $conn->insert_id; $target_dir = "../eventimages/"; $imageFileType = strtolower(pathinfo($_FILES['images']['name'],PATHINFO_EXTENSION)); $target_file = "../eventimages/" . "EI_".$last_id.".". $imageFileType; move_uploaded_file($_FILES["images"]["tmp_name"], $target_file); $target_file = "EI_".$last_id.".". $imageFileType; $stmt = $conn->prepare("update eventimages set Imagepath=? where Event_image_id=?"); $stmt->bind_param("ss",$target_file,$last_id ); //print_r($stmt); // $stmt->execute(); if ($stmt->execute()) { echo "<script>alert('Event Image added successfully.'); window.location.href='eventimageslist.php';</script>"; exit(); } else { echo "<script>alert('Insert failed. Please try again.');</script>"; } } include_once('header.php'); ?> <div class="main-panel"> <div class="content-wrapper"> <div class="row"> <div class="col-md-12 grid-margin stretch-card"> <div class="card"> <div class="card-body"> <h4 class="card-title" style="font-size:30px">Add Event Image</h4> <form class="forms-sample" method="post" autocomplete="off" enctype="multipart/form-data"> <div class="form-group"> <label>Event</label> <select class="form-control" id="eventid" name="eventid" required> <option value="" disabled selected>Select an Event</option> <?php while ($row = $events_result->fetch_assoc()): ?> <option value="<?php echo htmlspecialchars($row['Event_id']); ?>"> <?php echo htmlspecialchars($row['EventTitle']); ?> </option> <?php endwhile; ?> </select> </div> <div class="form-group"> <label>Image URL</label> <input type="file" class="form-control" id="images" name="images" placeholder="Enter image URL" required> </div> <button type="submit" class="btn btn-primary mr-2">Add Event Image</button> </form> </div> </div> </div> </div> </div> </div> <?php include_once('footer.php'); ?>