<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Pop extends CI_Controller {
	public function __construct()
	{
		parent::__construct();
		session_start();
		
		$this->load->model('main_m');
		$this->load->model('email_m');
		$this->load->model('events_m');
	}
	
	
	public function index()
	{		
		$listing = $this->email_m->get_all();
		
		foreach($listing as $i)
		{
			$promo_code = '';
			$promo_code = $i['promo_code'];
			$num_of_participants = '';
			$num_of_participants = $i['num_of_participants'];
			
			if($promo_code != '')
			{
				$url = "https://imas.org.sg/imasconference2026/main/index.php/api"; // Change to your target API URL

				$fields = [
					"codetitle" => $promo_code,
					"complimentary" => $num_of_participants,
					"datetimeadded" => '2026-03-12 12:00:00',
				];
				
				$fields_string = '';
				
				foreach($fields as $key=>$value) { 
					$fields_string .= $key.'='.$value.'&'; 
				 }
				 
				
				$ch = curl_init($url);
				curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
				curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
				curl_setopt($ch,CURLOPT_POST,count($fields));

				$response = curl_exec($ch);

				curl_close($ch);
				
			}
			
		}
		
		
		
	}
	

	
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */