<?php

print_r($_POST);

if (isset($_GET["Address"]))						    {$Address=$_GET["Address"];}
	elseif (isset($_POST["Address"]))            {$Address=$_POST["Address"];}
if (isset($_GET["callerid"]))						    {$callerid=$_GET["callerid"];}
	elseif (isset($_POST["callerid"]))            {$callerid=$_POST["callerid"];}
if (isset($_GET["City"]))						    {$City=$_GET["City"];}
  elseif (isset($_POST["City"]))            {$City=$_POST["City"];}
if (isset($_GET["Currently_Insured"]))						    {$Currently_Insured=$_GET["Currently_Insured"];}
  elseif (isset($_POST["Currently_Insured"]))            {$Currently_Insured=$_POST["Currently_Insured"];}
if (isset($_GET["DOB"]))						    {$DOB=$_GET["DOB"];}
  elseif (isset($_POST["DOB"]))            {$DOB=$_POST["DOB"];}
if (isset($_GET["Email"]))						    {$Email=$_GET["Email"];}
  elseif (isset($_POST["Email"]))            {$Email=$_POST["Email"];}
if (isset($_GET["First_Name"]))						    {$First_Name=$_GET["First_Name"];}
  elseif (isset($_POST["First_Name"]))            {$First_Name=$_POST["First_Name"];}
if (isset($_GET["Form_Completed_at"]))						    {$Form_Completed_at=$_GET["Form_Completed_at"];}
  elseif (isset($_POST["Form_Completed_at"]))            {$Form_Completed_at=$_POST["Form_Completed_at"];}
if (isset($_GET["Gender"]))						    {$Gender=$_GET["Gender"];}
  elseif (isset($_POST["Gender"]))            {$Gender=$_POST["Gender"];}
if (isset($_GET["jornaya_lead"]))						    {$jornaya_lead=$_GET["jornaya_lead"];}
  elseif (isset($_POST["jornaya_lead"]))            {$jornaya_lead=$_POST["jornaya_lead"];}
if (isset($_GET["Last_Name"]))						    {$Last_Name=$_GET["Last_Name"];}
  elseif (isset($_POST["Last_Name"]))            {$Last_Name=$_POST["Last_Name"];}
if (isset($_GET["State"]))						    {$State=$_GET["State"];}
  elseif (isset($_POST["State"]))            {$State=$_POST["State"];}
if (isset($_GET["Submission_URL"]))						    {$Submission_URL=$_GET["Submission_URL"];}
  elseif (isset($_POST["Submission_URL"]))            {$Submission_URL=$_POST["Submission_URL"];}
if (isset($_GET["trusted_form_cert_id"]))						    {$trusted_form_cert_id=$_GET["trusted_form_cert_id"];}
  elseif (isset($_POST["trusted_form_cert_id"]))            {$trusted_form_cert_id=$_POST["trusted_form_cert_id"];}
if (isset($_GET["User_IP"]))						    {$User_IP=$_GET["User_IP"];}
	elseif (isset($_POST["User_IP"]))            {$User_IP=$_POST["User_IP"];}
if (isset($_GET["zip_Code"]))						    {$zip_Code=$_GET["zip_Code"];}
  elseif (isset($_POST["zip_Code"]))            {$zip_Code=$_POST["zip_Code"];}

if (isset($_GET["submit"]))						    {$submit=$_GET["submit"];}
	elseif (isset($_POST["submit"]))            {$submit=$_POST["submit"];}

	if($submit)
	{
		$data['Address'] 							= $Address ;
		$data['callerid'] 						= $callerid ;
		$data['City'] 								= $City ;
		$data['Currently_Insured'] 		= ($Currently_Insured == "true") ? true : false ;
		$data['DOB'] 									= $DOB ;
		$data['Email'] 								= $Email ;
		$data['First_Name'] 					= $First_Name ;
		$data['Form_Completed_at'] 		= $Form_Completed_at ;
		$data['Gender'] 							= $Gender ;
		$data['jornaya_lead'] 				= $jornaya_lead ;
		$data['Last_Name']						= $Last_Name ;
		$data['State'] 								= $State ;
		$data['Submission_URL'] 			= $Submission_URL ;
		$data['trusted_form_cert_id'] = $trusted_form_cert_id ;
		$data['User_IP'] 							= $User_IP ;
		$data['zip_Code'] 						= $zip_Code ;
   	
   	foreach( $data as $key => $key_value )
   	{
        $query_array[] = urlencode( $key ) . '=' . urlencode( $key_value );
    }
    $query_string = implode('&', $query_array);
		
		$curl_connection = curl_init('https://display.ringba.com/enrich/1943612070821889278?'.$query_string);
		curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
    curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);

    $response = json_decode(curl_exec($curl_connection), true);

    if(isset($response['status']) && $response['status'] == 'ok')
    {
    	echo "Successfully send.";
    }
    else
    {
    	echo "Somethin went wrong";
    }

	}


	