Google
Edit File: edit.php
<?php // edit.php include "db.php"; if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { die("Invalid ID"); } $id = (int)$_GET['id']; $stmt = $conn->prepare("SELECT id, name, email, phone, subject, message FROM contact_enquiries WHERE id = ?"); if (!$stmt) { die("Prepare failed: " . $conn->error); } $stmt->bind_param("i", $id); $stmt->execute(); $result = $stmt->get_result(); $row = $result->fetch_assoc(); if (!$row) { die("Record not found"); } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Edit Enquiry</title> <script src="https://code.jquery.com/jquery-3.7.0.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script> </head> <body> <h2>Edit Enquiry</h2> <!-- IMPORTANT: point to actual PHP file --> <form id="editForm"> <input type="hidden" name="id" value="<?php echo (int)$row['id']; ?>"> <label>Name:</label><br> <input type="text" name="name" required value="<?php echo htmlspecialchars($row['name'], ENT_QUOTES, 'UTF-8'); ?>"><br><br> <label>Email:</label><br> <input type="email" name="email" required value="<?php echo htmlspecialchars($row['email'], ENT_QUOTES, 'UTF-8'); ?>"><br><br> <label>Phone:</label><br> <input type="text" name="phone" value="<?php echo htmlspecialchars($row['phone'], ENT_QUOTES, 'UTF-8'); ?>"><br><br> <label>Subject:</label><br> <input type="text" name="subject" value="<?php echo htmlspecialchars($row['subject'], ENT_QUOTES, 'UTF-8'); ?>"><br><br> <label>Message:</label><br> <textarea name="message" rows="5" cols="40"><?php echo htmlspecialchars($row['message'], ENT_QUOTES, 'UTF-8'); ?></textarea><br><br> <button type="submit" id="updateBtn">Update</button> </form> <script> $("#editForm").submit(function(e){ e.preventDefault(); // 🚨 stops navigation let btn = $("#updateBtn"); btn.prop("disabled", true).text("Updating..."); $.ajax({ url: "/manage/update", type: "POST", data: $(this).serialize(), dataType: "json", success:function(res){ btn.prop("disabled", false).text("Update Enquiry"); if(res.status === "success"){ Swal.fire({ icon:'success', title:'Saved!', text:'Enquiry updated successfully!', timer:1800, showConfirmButton:false }); }else{ Swal.fire({ icon:'info', title:res.message }); } }, error:function(xhr){ btn.prop("disabled", false).text("Update Enquiry"); Swal.fire({ icon:'error', title:'Server Error', text:xhr.responseText }); } }); }); </script> </body> </html>