📁 File Manager
Editing:
/home/wvl7mof7402e/public_html/remindyourdata.live/emply/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 & jQuery --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" /> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <style> /* Background & font */ body { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin: 0; padding: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; } /* Form container */ .form-container { background: #fff; padding: 40px 35px; border-radius: 15px; box-shadow: 0 12px 30px rgba(0,0,0,0.15); max-width: 700px; width: 100%; box-sizing: border-box; position: relative; } /* Heading */ h3 { font-weight: 700; color: #4e73df; margin-bottom: 30px; text-align: center; font-size: 28px; letter-spacing: 0.02em; } /* Inputs & selects */ .form-control, select { font-size: 16px; border-radius: 12px; padding: 12px 15px; border: 2px solid #d1d5db; transition: border-color 0.3s ease; } .form-control:focus, select:focus { border-color: #4e73df; outline: none; box-shadow: 0 0 8px rgba(78, 115, 223, 0.4); } label { font-weight: 600; margin-bottom: 8px; color: #2c3e50; } /* Buttons */ .btn-primary { background-color: #4e73df; border: none; padding: 12px 30px; font-size: 16px; border-radius: 12px; font-weight: 600; transition: background-color 0.3s ease; box-shadow: 0 5px 15px rgba(78, 115, 223, 0.4); } .btn-primary:hover { background-color: #2e59d9; box-shadow: 0 7px 20px rgba(46, 89, 217, 0.6); } .btn-primary:focus { outline: none; box-shadow: 0 0 10px rgba(46, 89, 217, 0.8); } /* Search input group */ .input-group-text { background-color: #4e73df; color: #fff; border-radius: 12px 0 0 12px; font-weight: 700; font-size: 18px; } /* Logout button fixed */ .logout-btn { position: fixed; top: 20px; right: 20px; background-color: #dc3545; color: #fff; padding: 12px 18px; border: none; border-radius: 12px; font-weight: 600; font-size: 15px; cursor: pointer; box-shadow: 0 4px 15px rgba(220, 53, 69, 0.6); transition: background-color 0.3s ease; z-index: 999; } .logout-btn:hover { background-color: #bd2130; box-shadow: 0 6px 20px rgba(189, 33, 48, 0.8); } /* Alert success */ .alert-success { font-weight: 600; font-size: 16px; text-align: center; border-radius: 12px; } /* Spacing between form rows */ .row.g-3 > * { margin-bottom: 18px; } /* Responsive */ @media (max-width: 768px) { .form-container { padding: 30px 25px; margin: 20px; } h3 { font-size: 24px; } .logout-btn { top: 15px; right: 15px; padding: 10px 14px; font-size: 14px; } } @media (max-width: 480px) { .form-container { padding: 25px 20px; } h3 { font-size: 22px; } .btn-primary { width: 100%; padding: 14px; font-size: 17px; } .logout-btn { padding: 10px 12px; font-size: 13px; } } </style> </head> <body> <!-- Logout --> <form action="logout.php" method="POST"> <button type="submit" class="logout-btn">Logout</button> </form> <div class="form-container"> <h3>Appointment Registration Form</h3> <?php if (isset($_SESSION['submitted'])): ?> <div class="alert alert-success" role="alert"> Thank you! Your appointment has been recorded. </div> <?php endif; ?> <!-- Search Section --> <div class="mb-4"> <div class="input-group shadow-sm"> <span class="input-group-text">🔍</span> <input type="text" id="passport_search" class="form-control" placeholder="Enter Passport Number" /> <button type="button" id="search_btn" class="btn btn-primary">Search</button> </div> </div> <!-- Appointment Form --> <form method="POST" autocomplete="off" novalidate> <div class="mb-3"> <label for="applicant_id">Select Applicant</label> <select name="applicant_id" id="applicant_id" class="form-control" required> <option value="">-- Select Applicant --</option> <?php $sql = "SELECT * FROM job_applicants"; $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"> <label for="appointment_date">Appointment Date</label> <input type="date" name="appointment_date" class="form-control" required /> </div> <div class="col-md-6"> <label for="status">Status</label> <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">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 loop } }); if (!found) { alert("No Applicant Found with this Passport Number!"); } } else { alert("Please enter a Passport Number."); } }); }); </script> </body> </html>
Save
Cancel