📁 File Manager
Editing:
/home/wvl7mof7402e/public_html/remindyourdata.live/admin/appointment_form.php
<?php session_start(); include "dbconnect.php"; // Prevent double submissions if ($_SERVER["REQUEST_METHOD"] == "POST" && !isset($_SESSION['submitted'])) { $_SESSION['submitted'] = true; $applicant_id = $_POST['applicant_id']; $appointment_date = $_POST['appointment_date']; $status = $_POST['status']; $sql_check = "SELECT * FROM appointments WHERE applicant_id = '$applicant_id' AND appointment_date = '$appointment_date'"; $result_check = $con->query($sql_check); if ($result_check->num_rows > 0) { echo "<script>alert('Appointment already exists for this applicant with the same date.');</script>"; } else { $sql = "INSERT INTO appointments (applicant_id, appointment_date, status) VALUES ('$applicant_id', '$appointment_date', '$status')"; if ($con->query($sql) === TRUE) { echo "<script>alert('Appointment Added Successfully');</script>"; } else { echo "<script>alert('Error: " . $con->error . "');</script>"; } } } elseif (isset($_SESSION['submitted'])) { echo "<script>alert('You have already submitted the form.');</script>"; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Appointment Registration</title> <meta name="viewport" content="width=device-width, initial-scale=1" /> <!-- Bootstrap CSS & Bootstrap Icons --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" /> <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet" /> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <style> body { background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%); font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; min-height: 100vh; margin: 0; padding: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 15px; } .form-container { background: #fff; padding: 30px 35px; border-radius: 15px; box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2); max-width: 700px; width: 100%; transition: all 0.3s ease-in-out; } .form-container:hover { box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3); } h3 { font-weight: 700; color: #2575fc; text-align: center; margin-bottom: 25px; letter-spacing: 1px; } label { font-weight: 600; color: #333; } .form-control, select { border-radius: 12px; font-size: 16px; padding-left: 45px; /* space for icon */ height: 45px; border: 2px solid #2575fc; transition: border-color 0.3s; } .form-control:focus, select:focus { border-color: #6a11cb; box-shadow: 0 0 8px #6a11cb; outline: none; } .input-group-text { background-color: #2575fc; color: white; border-radius: 12px 0 0 12px; border: 2px solid #2575fc; font-size: 18px; width: 45px; justify-content: center; } .btn-primary { background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%); border: none; border-radius: 12px; padding: 12px 30px; font-size: 16px; font-weight: 600; transition: background 0.4s ease; box-shadow: 0 5px 15px rgba(38, 57, 255, 0.4); } .btn-primary:hover { background: linear-gradient(135deg, #2575fc 0%, #6a11cb 100%); box-shadow: 0 8px 20px rgba(106, 17, 203, 0.6); } .logout-btn { position: fixed; top: 20px; right: 20px; background-color: #dc3545; color: #fff; padding: 10px 18px; border: none; border-radius: 12px; font-weight: 600; box-shadow: 0 5px 15px rgba(220, 53, 69, 0.6); transition: background-color 0.3s ease; z-index: 1050; cursor: pointer; } .logout-btn:hover { background-color: #b02a37; } /* Icon positioning inside inputs */ .form-icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: #2575fc; font-size: 20px; pointer-events: none; z-index: 10; } /* Position relative wrapper for inputs with icons */ .input-with-icon { position: relative; } /* Alerts */ .alert { border-radius: 12px; font-weight: 600; } /* Responsive */ @media (max-width: 768px) { body { padding: 10px; } .form-container { padding: 20px; max-width: 100%; } .logout-btn { top: 10px; right: 10px; padding: 8px 14px; font-size: 14px; } .form-control, select { font-size: 14px; height: 42px; padding-left: 40px; } .form-icon { font-size: 18px; left: 12px; } .btn-primary { padding: 10px 25px; font-size: 14px; } } </style> </head> <body> <!-- Logout --> <form action="logout.php" method="POST"> <button type="submit" class="logout-btn" title="Logout"> <i class="bi bi-box-arrow-right"></i> Logout </button> </form> <div class="form-container shadow-sm"> <h3>Appointment Registration Form</h3> <?php if (isset($_SESSION['submitted'])): ?> <div class="alert alert-success text-center" role="alert"> <i class="bi bi-check-circle-fill"></i> Thank you! Your appointment has been recorded. </div> <?php endif; ?> <!-- Search Section --> <div class="mb-4"> <div class="input-group"> <span class="input-group-text"><i class="bi bi-search"></i></span> <input type="text" id="passport_search" class="form-control" placeholder="Enter Passport Number" aria-label="Passport Number Search" /> <button type="button" id="search_btn" class="btn btn-primary" aria-label="Search Applicant"> <i class="bi bi-search"></i> Search </button> </div> </div> <!-- Appointment Form --> <form method="POST" autocomplete="off" novalidate> <div class="mb-3 input-with-icon"> <label for="applicant_id">Select Applicant</label> <i class="bi bi-person form-icon"></i> <select name="applicant_id" id="applicant_id" class="form-control" required> <option value="" selected disabled>-- Select Applicant --</option> <?php $sql = "SELECT * FROM job_applicants ORDER BY name ASC"; $result = $con->query($sql); while ($row = $result->fetch_assoc()) { ?> <option value="<?= htmlspecialchars($row['id']) ?>" data-passport="<?= htmlspecialchars($row['passport_no']) ?>" data-reference="<?= htmlspecialchars($row['reference']) ?>"> <?= htmlspecialchars($row['name']) ?> (<?= htmlspecialchars($row['passport_no']) ?>) </option> <?php } ?> </select> </div> <div class="row g-3"> <div class="col-md-6 input-with-icon"> <label for="appointment_date">Appointment Date</label> <i class="bi bi-calendar-date form-icon"></i> <input type="date" name="appointment_date" class="form-control" required /> </div> <div class="col-md-6 input-with-icon"> <label for="status">Status</label> <i class="bi bi-info-circle form-icon"></i> <select name="status" class="form-control" required> <option value="done">Done</option> <option value="not done">Not Done</option> </select> </div> </div> <div class="text-center mt-4"> <button type="submit" class="btn btn-primary"> <i class="bi bi-check2-circle"></i> Save Appointment </button> </div> </form> </div> <script> $(document).ready(function () { $("#search_btn").click(function () { let passportNo = $("#passport_search").val().trim(); let found = false; if (passportNo !== "") { $("#applicant_id option").each(function () { if ($(this).data("passport") === passportNo) { $(this).prop("selected", true); found = true; return false; // break each loop } }); if (!found) { alert("No Applicant Found with this Passport Number!"); } } else { alert("Please enter a Passport Number."); } }); }); </script> <!-- Bootstrap JS Bundle --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> </body> </html>
Save
Cancel