📁 File Manager
Editing:
/home/wvl7mof7402e/www/remindyourdata.live/admin/approvallistedit.php
<?php session_start(); include "dbconnect.php"; // Check for applicant ID if (!isset($_GET['id'])) { echo "<script>alert('No applicant selected.'); window.location.href='approvallistedit.php';</script>"; exit; } $applicant_id = intval($_GET['id']); // Fetch record $sql = "SELECT * FROM work_permit_approval WHERE applicant_id = ?"; $stmt = $con->prepare($sql); $stmt->bind_param("i", $applicant_id); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows == 0) { echo "<script>alert('No work permit approval record found for this applicant.'); window.location.href='approvallistedit.php';</script>"; exit; } $data = $result->fetch_assoc(); // Form submitted if ($_SERVER["REQUEST_METHOD"] == "POST") { $work_permit_received = $_POST['work_permit_received']; $approval_date = $_POST['approval_date']; $file_path = $data['file_upload']; // Keep existing file // File upload if (isset($_FILES['work_permit_upload']) && $_FILES['work_permit_upload']['error'] == 0) { $file_name = $_FILES['work_permit_upload']['name']; $file_tmp = $_FILES['work_permit_upload']['tmp_name']; $ext = strtolower(pathinfo($file_name, PATHINFO_EXTENSION)); $allowed = ['jpg', 'jpeg', 'png', 'pdf']; if (in_array($ext, $allowed)) { $upload_dir = 'uploads/'; $file_path = $upload_dir . uniqid() . '_' . basename($file_name); move_uploaded_file($file_tmp, $file_path); } else { echo "<script>alert('Invalid file type.');</script>"; exit; } } // Update DB $update = "UPDATE work_permit_approval SET work_permit_received = ?, approval_date = ?, file_upload = ? WHERE applicant_id = ?"; $stmt = $con->prepare($update); $stmt->bind_param("sssi", $work_permit_received, $approval_date, $file_path, $applicant_id); if ($stmt->execute()) { echo "<script>alert('Record updated successfully'); window.location.href='approvallistedit.php';</script>"; } else { echo "<script>alert('Update failed');</script>"; } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Edit Work Permit Approval</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Bootstrap + Font Awesome --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <style> body { background: linear-gradient(to right, #eef2f3, #8e9eab); font-family: 'Segoe UI', sans-serif; } .form-container { background-color: #ffffff; padding: 30px; border-radius: 10px; margin-top: 50px; box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1); } h3 { color: #2c3e50; font-weight: bold; } .form-label i { color: #3498db; margin-right: 5px; } .btn-primary i, .btn-secondary i { margin-right: 5px; } .logout-btn { position: fixed; top: 20px; right: 20px; background-color: #e74c3c; border: none; padding: 10px 16px; color: white; border-radius: 50px; font-weight: bold; z-index: 1000; } .logout-btn i { margin-right: 6px; } .logout-btn:hover { background-color: #c0392b; } @media screen and (max-width: 768px) { .form-container { padding: 20px; margin-top: 30px; } .logout-btn { padding: 8px 12px; font-size: 14px; top: 10px; right: 10px; } } </style> </head> <body> <!-- Logout --> <form method="POST" action="logout.php"> <button class="logout-btn"><i class="fas fa-sign-out-alt"></i> Logout</button> </form> <div class="container"> <div class="form-container"> <h3 class="text-center mb-4"><i class="fas fa-pen-to-square"></i> Edit Work Permit Approval</h3> <form method="POST" enctype="multipart/form-data"> <div class="mb-3"> <label class="form-label"><i class="fas fa-id-badge"></i>Applicant ID</label> <input type="text" class="form-control" value="<?= $applicant_id ?>" readonly> </div> <div class="mb-3"> <label class="form-label"><i class="fas fa-check-circle"></i>Work Permit Received</label> <select name="work_permit_received" class="form-select" required> <option value="Yes" <?= $data['work_permit_received'] == 'Yes' ? 'selected' : '' ?>>Yes</option> <option value="No" <?= $data['work_permit_received'] == 'No' ? 'selected' : '' ?>>No</option> </select> </div> <div class="mb-3"> <label class="form-label"><i class="fas fa-calendar-alt"></i>Approval Date</label> <input type="date" name="approval_date" class="form-control" value="<?= $data['approval_date'] ?>" required> </div> <div class="mb-3"> <label class="form-label"><i class="fas fa-file-alt"></i>Current Uploaded File</label><br> <?php if (!empty($data['file_upload'])): ?> <a href="<?= $data['file_upload'] ?>" class="btn btn-outline-info btn-sm" target="_blank"> <i class="fas fa-eye"></i> View File </a> <?php else: ?> <span class="text-muted">No file uploaded.</span> <?php endif; ?> </div> <div class="mb-3"> <label class="form-label"><i class="fas fa-upload"></i>Upload New Document (Optional)</label> <input type="file" name="work_permit_upload" class="form-control" accept=".jpg,.jpeg,.png,.pdf"> </div> <div class="text-center"> <button type="submit" class="btn btn-primary"> <i class="fas fa-save"></i> Update Record </button> <a href="approvallistedit.php" class="btn btn-secondary"> <i class="fas fa-arrow-left"></i> Cancel </a> </div> </form> </div> </div> </body> </html>
Save
Cancel