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:

"; MailService::sendMail($admin_email, $admin_subject, $admin_body, strip_tags($admin_body)); // Send user the edit link $edit_link = "http://{$_SERVER['HTTP_HOST']}/edit.php?token={$edit_token}"; $user_subject = 'Your Registration Details'; $user_body = "

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; }