query($sql); if ($result->num_rows == 0) { redirect(SITE_URL . ADMIN_PATH . '/manage-tickets.php'); } $ticket = $result->fetch_assoc(); // Handle form submission if ($_SERVER['REQUEST_METHOD'] === 'POST') { $admin_reply = clean_input($_POST['admin_reply']); $new_status = clean_input($_POST['ticket_status']); $admin_id = $_SESSION['admin_id']; if (empty($admin_reply)) { $error = "Reply message is required"; } else { // Update ticket $update_sql = "UPDATE contact_messages SET admin_reply = '$admin_reply', ticket_status = '$new_status', replied_at = NOW(), replied_by = $admin_id WHERE id = $ticket_id"; if ($conn->query($update_sql)) { $success = "Reply sent successfully!"; // Check if this is member or visitor $is_member = !empty($ticket['member_id']); // Send email notification to user $email_subject = "Response to Your Query - Ticket #$ticket_id"; if ($is_member) { // Member email (existing format) $email_message = "
Dear " . htmlspecialchars($ticket['name']) . ",
Thank you for contacting us. We have reviewed your query and here is our response:
Your Message:
" . nl2br(htmlspecialchars($ticket['message'])) . "
Our Response:
" . nl2br($admin_reply) . "
Ticket #$ticket_id - Status: " . ucfirst(str_replace('_', ' ', $new_status)) . "
You can view your tickets anytime by logging in to your account and visiting the 'My Tickets' section.
If you have any further questions, please don't hesitate to contact us again.
Best regards,
Paid Survey Hub Support Team
Dear " . htmlspecialchars($ticket['name']) . ",
Thank you for contacting us. We have reviewed your query and here is our response:
Your Message:
" . nl2br(htmlspecialchars($ticket['message'])) . "
Our Response:
" . nl2br($admin_reply) . "
Ticket #$ticket_id - Status: " . ucfirst(str_replace('_', ' ', $new_status)) . "
Have a follow-up question?
Click the button below to respond to this ticket and continue the conversation with our support team.
We hope this resolves your query. If you need further assistance, just click the respond button above.
Best regards,
Paid Survey Hub Support Team
Ticket #$ticket_id
Type:
Member Query Visitor QuerySubmitted:
Last Reply: