Car Make: " . htmlspecialchars($details['carMake']) . ""; $output .= "
  • Car Model: " . htmlspecialchars($details['carModel']) . "
  • "; $output .= "
  • Year of Manufacture: " . htmlspecialchars($details['carYear']) . "
  • "; break; case 'Health': $output .= "
  • Number of Dependents: " . htmlspecialchars($details['healthDependents']) . "
  • "; break; case 'Life': $output .= "
  • Coverage Amount: $" . number_format($details['lifeCoverage'], 2) . "
  • "; break; case 'Home': $output .= "
  • Property Type: " . htmlspecialchars($details['homeType']) . "
  • "; break; } return $output; } $show_success_message = false; if ($_SERVER['REQUEST_METHOD'] === 'POST') { try { $pdo = db(); $stmt = $pdo->prepare( "INSERT INTO subscriptions (fullName, email, phone, insuranceType, carMake, carModel, carYear, healthDependents, lifeCoverage, homeType) " . "VALUES (:fullName, :email, :phone, :insuranceType, :carMake, :carModel, :carYear, :healthDependents, :lifeCoverage, :homeType)" ); $stmt->execute([ ':fullName' => $personal_details['fullName'], ':email' => $personal_details['email'], ':phone' => $personal_details['phone'], ':insuranceType' => $insurance_details['insuranceType'], ':carMake' => $insurance_details['carMake'] ?? null, ':carModel' => $insurance_details['carModel'] ?? null, ':carYear' => $insurance_details['carYear'] ?: null, ':healthDependents' => $insurance_details['healthDependents'] ?: null, ':lifeCoverage' => $insurance_details['lifeCoverage'] ?: null, ':homeType' => $insurance_details['homeType'] ?? null, ]); $submission_id = $pdo->lastInsertId(); // --- Send Confirmation Email to User --- $user_subject = "Your Subscription to SecureLife is Confirmed!"; $user_body_html = "

    Welcome to SecureLife, " . htmlspecialchars($personal_details['fullName']) . "!

    "; $user_body_html .= "

    We have received your application for " . htmlspecialchars($insurance_details['insuranceType']) . " insurance. Here is a summary of your submission:

    "; $user_body_html .= ""; $user_body_html .= "

    We will review your application and get back to you shortly. Your submission ID is: {$submission_id}

    "; MailService::sendMail($personal_details['email'], $user_subject, $user_body_html); // --- Send Notification Email to Admin --- $admin_subject = "New Insurance Application Received (#{$submission_id})"; $admin_body_html = "

    New Submission

    "; $admin_body_html .= "

    A new insurance application has been submitted by " . htmlspecialchars($personal_details['fullName']) . ".

    "; $admin_body_html .= "
    Personal Details
    "; $admin_body_html .= "
    Insurance Details
    "; $admin_body_html .= "

    You can view this submission in the Admin Dashboard.

    "; MailService::sendMail(null, $admin_subject, $admin_body_html); // $to = null uses MAIL_TO from env // Clear the session and show a success message session_unset(); session_destroy(); $show_success_message = true; } catch (PDOException $e) { error_log("Database error: " . $e->getMessage()); die("An error occurred. Please try again later."); } catch (Exception $e) { error_log("Mail sending error: " . $e->getMessage()); die("An error occurred. Please try again later."); } } ?> Confirm Subscription - SecureLife

    Subscription Complete!

    Thank you for choosing SecureLife. A confirmation email has been sent to you. We will be in touch shortly.

    Back to Home

    Confirm Your Details

    Step 3: Please review your information before confirming.

    Personal Details
    • Full Name:
    • Email:
    • Phone:
    Insurance Details
    • Insurance Type:
    ← Go Back