prepare( 'INSERT INTO registrations (fullname, email, mobile_no, job_description, edit_token) VALUES (?, ?, ?, ?, ?)' ); $stmt->execute([$fullname, $email, $mobile_no, $job_description, $edit_token]); $_SESSION['success_message'] = 'Registration successful!'; // Send admin notification $admin_email = getenv('MAIL_TO') ?: 'admin@example.com'; // Fallback $admin_subject = 'New Registration Submitted'; $admin_body = "
A new registration has been submitted:
Thank you for registering.
You can edit or delete your registration using this link: {$edit_link}
"; MailService::sendMail($email, $user_subject, $user_body, strip_tags($user_body)); } catch (PDOException $e) { error_log($e->getMessage()); $_SESSION['error_message'] = 'An error occurred. Please try again.'; } header('Location: index.php'); exit; }