<?php
	include('page_load.php');
	
	if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
		exit();
	}
	
	// They already posted -- End it
	if ($_SESSION["initial_prospect"] === true) {
			exit();
		}

	$campaign_id = $configs->incomplete_prospect_campaign_id;
	
	
	$data = array(
		'sessionId'			=> $_SESSION["konnektive_sessionId"],
		'campaignId'		=> $campaign_id,
		'ipAddress'			=> getUserIpAddr(),
		'firstName'			=> trim($_POST['shipFirstName']),
		'lastName'			=> trim($_POST['shipLastName']),
		'phoneNumber'		=> trim($_POST['phoneNumber']),
		'emailAddress'	=> trim($_POST['emailAddress']),
		'affId'					=> trim($_SESSION['affId']),
		'sourceValue1'	=> trim($_SESSION['c1']),
		'sourceValue2'	=> trim($_SESSION['c2']),
		'sourceValue3'	=> trim($_SESSION['c3'])
	);
	
	$resp = $konnektive->import_lead($data);
	
	$lead = json_decode($resp);
	
	if ($lead->result === "SUCCESS") {
		$_SESSION["orderId"] = $lead->message->orderId;
		$_SESSION["initial_prospect"] = True;	
		exit();
	} else {
		$_SESSION["initial_prospect"] = False;	
	}
	
	$_SESSION["initial_prospect"] = False;	
	exit();