PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php @include 'config.php'; if (isset($_GET['id'])) { $reservation_id = $_GET['id']; } session_start(); if (!isset($_SESSION['admin_name'])) { header('location:login_form.php'); } if (isset($_POST['submit'])) { $member_name = $_POST['member_name']; $member_email = $_POST['member_email']; $contact_number = $_POST['contact_number']; $equipment_name = $_POST['equipment_name']; $date = $_POST['date']; $start_time = $_POST['start_time']; $end_time = $_POST['end_time']; $sql = "UPDATE `reservation` SET `member_name`='$member_name', `member_email`='$member_email', `contact_number`='$contact_number', `equipment_name`='$equipment_name', `date`='$date', `start_time`='$start_time', `end_time`='$end_time' WHERE reservation_id = '$reservation_id'"; $result = mysqli_query($conn, $sql); if ($result) { header("Location: admin_editReservation.php?msg=Equipment reservation details updated successfully"); exit; } else { echo "Failed: " . mysqli_error($conn); } } $sql = "SELECT equipment_name FROM reservation WHERE reservation_id = 1"; $stmt = mysqli_prepare($conn, $sql); mysqli_stmt_bind_param($stmt, "i", $reservation_id); mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); $row = mysqli_fetch_array($result); $selectedValue = $row['equipment_name']; ?> <!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.0"> <title>Edit Equipment Reservation</title> <!-- Boxicons --> <link href='https://unpkg.com/boxicons@2.0.9/css/boxicons.min.css' rel='stylesheet'> <!-- custom css file link --> <link rel="stylesheet" href="css/form.css"> <link rel="stylesheet" href="css/dashboard.css"> <!-- Font Awesome --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css" integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ==" crossorigin="anonymous" referrerpolicy="no-referrer" /> </head> <body> <!-- SIDEBAR --> <section id="sidebar"> <a href="#" class="brand"> <i class='bx bx-run'></i> <span class="text">GoFit</span> </a> <ul class="side-menu top"> <li> <a href="admin_dashboard.php"> <i class='bx bxs-dashboard'></i> <span class="text">Dashboard</span> </a> </li> <li> <a href="admin_member.php"> <i class='bx bxs-group'></i> <span class="text">Members</span> </a> </li> <li> <a href="admin_class.php"> <i class='bx bxs-calendar'></i> <span class="text">Classes & Events</span> </a> </li> <li class="active"> <a href="admin_equipment.php"> <i class='bx bx-dumbbell'></i> <span class="text">Equipment</span> </a> </li> </ul> <ul class="side-menu"> <li> <a href="logout.php" class="logout"> <i class='bx bxs-log-out-circle'></i> <span class="text">Logout</span> </a> </li> </ul> </section> <!-- SIDEBAR --> <!-- CONTENT --> <section id="content"> <nav> <i class='bx bx-menu'></i> <h1>Welcome admin, <span> <?php echo $_SESSION['admin_name'] ?> </span>!</h1> </nav> <!-- MAIN --> <main> <div class="head-title"> <div class="left"> <h1>Equipment Reservation Details</h1> <ul class="breadcrumb"> <li> <a href="admin_dashboard.php">Home</a> </li> <li><i class='bx bx-chevron-right'></i></li> <li> <a href="admin_equipment.php">Equipment</a> </li> <i class='bx bx-chevron-right'></i></li> <li> <a href="admin_memberReservation.php">Equipment Reservation</a> </li> <i class='bx bx-chevron-right'></i></li> <li> <a class="active" href="admin_editReservation.php">Equipment Reservation Details</a> </li> </ul> </div> </div> <div class="form-container"> <?php $sql = "SELECT `equipment_name` FROM reservation WHERE reservation_id = ?"; $stmt = mysqli_prepare($conn, $sql); mysqli_stmt_bind_param($stmt, "i", $reservation_id); mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); $row = mysqli_fetch_array($result); $selectedValue = $row['equipment_name'] ?? 'x'; ?> <div class="form-container"> <form action="" method="post"> <h3>Equipment Reservation Details</h3> <p style="font-size: 14px; margin-bottom: 20px; font-style:italic; margin-top: 15px;"> Kindly update equipment reservation details. </p> <?php if (isset($error)) { foreach ($error as $error) { echo '<span class="error-msg">' . $error . '</span>'; }; }; $stmt = $conn->prepare("SELECT * FROM reservation WHERE reservation_id = ?"); $stmt->bind_param("i", $reservation_id); $stmt->execute(); $result = $stmt->get_result(); $row = $result->fetch_array(); ?> <?php $query = "SELECT * FROM equipment"; $stmt = mysqli_prepare($conn, $query); mysqli_stmt_execute($stmt); $result1 = mysqli_stmt_get_result($stmt); ?> <label for="name" style="display: inline-block; width: 90%; text-align: left; font-weight:bold; margin-top:10px;">Name:</label> <input type="text" id="member_name" name="member_name" required value="<?php echo $row['member_name'] ?>"> <label for="email" style="display: inline-block; width: 90%; text-align: left; font-weight:bold; margin-top:10px;">Email Address:</label> <input type="email" id="email" name="member_email" required value="<?php echo $row['member_email'] ?>"> <label for="phone" style="display: inline-block; width: 90%; text-align: left; font-weight:bold; margin-top:10px;">Contact Number:</label> <input type="tel" id="phone" name="contact_number" required value="<?php echo $row['contact_number'] ?>"> <label for="equipment" style="display: inline-block; width: 90%; text-align: left; font-weight:bold; margin-top:10px;">Equipment:</label> <select id="equipment_name" name="equipment_name"> <?php while ($row1 = mysqli_fetch_array($result1)) :; ?> <option value="<?php echo $row1[0]; ?>" <?php if ($row1[0] == $selectedValue) echo 'selected'; ?>><?php echo $row1[1]; ?></option> <?php endwhile; ?> </select> <label for="date" style="display: inline-block; width: 90%; text-align: left; font-weight:bold; margin-top:10px;">Date:</label> <input type="date" id="date" name="date" required value="<?php echo $row['date'] ?>"> <br> <label for="start-time" style="display: inline-block; width: 90%; text-align: left; font-weight:bold; margin-top:10px;">Start Time:</label> <input type="time" id="start-time" name="start_time" required value="<?php echo $row['start_time'] ?>"> <br> <label for="end-time" style="display: inline-block; width: 90%; text-align: left; font-weight:bold; margin-top:10px;">End Time:</label> <input type="time" id="end-time" name="end_time" required value="<?php echo $row['end_time'] ?>"> <input type="submit" name="submit" value="Save" class="form-btn" /> <input class="form-btn" type="button" onclick="window.location.replace('admin_memberReservation.php')" value="Cancel" /> </form> </div> </main> <!-- MAIN --> </section> <!-- CONTENT --> <script src="app.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script> </body> </html>
Show:  
Copy Clear