<?php
ob_start();
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);

  function postRequest($url, $parameters) {

    $url = 'https://chainsform.onrender.com/api/v1/forms/ltif/'.$url.'';
    $curl = curl_init($url);

    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_POST, true);

    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $headers = array(
      "Content-Type: application/json"
    );

    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

    $data = json_encode($parameters);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

    $resp = curl_exec($curl);
    curl_close($curl);

    $feedback = json_decode(($resp), true);

    return $feedback;
  }

  if (ISSET($_GET['type'])) {
    $authType = $_GET['type'];

    switch ($authType) {

      // ATTENDEE REGISTRATION
      case 'register':
        $header = 'Registration Successful';
        $subHeading = 'Thank you for registering for the Loveworld Trade & Investment Forum 2025';
        $paragraph = 'Your registration has been received successfully.<br>
        A confirmation email has been sent to your inbox. Please check your email for further event details and updates.';
        break;

      // EXHIBITOR APPLICATION
      case 'exhibitor':
        $header = 'Exhibitor Application Received';
        $subHeading = 'Thank you for applying to showcase at the Loveworld Trade & Investment Forum 2025';
        $paragraph = 'Your exhibitor application has been submitted successfully.<br>
        Our team will contact you shortly with booth allocation details and next steps.';
        break;

      // SPONSORSHIP APPLICATION
      case 'sponsor':
        $header = 'Sponsorship Application Submitted';
        $subHeading = 'Thank you for partnering with the Loveworld Trade & Investment Forum 2025';
        $paragraph = 'We appreciate your interest in sponsorship.<br>
        Our corporate relations team will reach out soon to discuss partnership details, visibility, and brand integration.';
        break;

      // PARTNER APPLICATION
      case 'partner':
        $header = 'Partnership Request Submitted';
        $subHeading = 'Thank you for choosing to partner with the Loveworld Trade & Investment Forum 2025';
        $paragraph = 'Your partnership interest has been received successfully.<br>
        Our partnership team will connect with you to explore collaboration opportunities and next steps.';
        break;

      // DEFAULT (if none provided)
      default:
        $header = 'Submission Successful';
        $subHeading = 'Your form has been successfully submitted';
        $paragraph = 'Thank you for reaching out. Our team will review your submission and get back to you shortly.';
        break;
    }
  }

?>
