<?php
require_once("include/config.php");
require_once("include/startup.php");

// ini_set('display_errors', 1);         
//     ini_set('display_startup_errors', 1);
//     error_reporting(E_ALL);                   

// require_once("include/email/sendEmail.php");
// require_once("include/classes/sendMail.class.php");
include 'header.php';

$AllTables = new AllTables();
$exhibitor = new exhibitor();
$Validation = new Validation();
$allform = new allform();

// form is getting submit through ajax   
if (isset($_POST['btn_submit'])) 
{
	$id = session_id();


	// echo "<pre>";                                
	//     print_r($_POST);               
	//     die();          
	$verif_box = $_REQUEST["verif_box"];

	//if(md5($verif_box).'a4xn' == $_COOKIE['tntcon'])
	//{
	if ($_POST['txt_form_field1'] == '' && $_POST['txt_form_field2'] == $id && $_POST['txt_iagree'] == 'on') {
		//           echo "<pre>";
		//      print_r($_POST);
		//   die();          
		$utm_source                                         = sanitize($_POST['txt_utm_source'], SQL + HTML);
		$utm_medium                                         = sanitize($_POST['txt_utm_medium'], SQL + HTML);
		$space 												= sanitize($_POST['txt_require'], SQL + HTML);
		$stall_area 										= sanitize($_POST['txt_stall_area'], SQL + HTML);
		$sponsorship_opportunity 						    = sanitize($_POST['txt_sponsorship_opportunity'], SQL + HTML);
		$fname 												= sanitize($_POST['txt_firstname'], SQL + HTML);
		$lname 												= sanitize($_POST['txt_lastname'], SQL + HTML);
		$company 											= sanitize($_POST['txt_company'], SQL + HTML);
		$designation 										= sanitize($_POST['txt_designation'], SQL + HTML);
		$email 												= sanitize($_POST['txt_email'], SQL + HTML);
		$phone 												= sanitize($_POST['txt_phone'], SQL + HTML);
		$country_code 								        = sanitize($_POST['txt_country_code'], SQL+HTML);
		$mobile 											= sanitize($_POST['txt_mobile'], SQL + HTML);
		$fromname            							    = sanitize($_POST['txt_fromname'], SQL + HTML);
		$fromemail            							    = sanitize($_POST['txt_fromemail'], SQL + HTML);
		$recipientname          						    = sanitize($_POST['txt_recipientname'], SQL + HTML);
		$recipientemail          						    = sanitize($_POST['txt_recipientemail'], SQL + HTML);
		$subject 											= sanitize($_POST['txt_subject'], SQL + HTML);
		//$form 											= sanitize($_POST['txt_form'], SQL+HTML);
		$redirectpagename									= sanitize($_POST['txt_redirect'], SQL + HTML);
		$formname											= sanitize($_POST['txt_formname'], SQL + HTML);
		$domainname 										= sanitize($_POST['txt_domainname'], SQL + HTML);
		$formtype                          			        = intval($_POST['txt_formtype']);

		$country 											= sanitize($_POST['txt_country'], SQL + HTML);
		$city 												= sanitize($_POST['txt_City'], SQL+HTML); 
        $state 												= sanitize($_POST['txt_state'], SQL+HTML);
		//$countryexpolde = explode('-',$country);
		//$countryname = $countryexpolde[1];
		$industrybelong 							        = sanitize($_POST['txt_industrybelong'], SQL + HTML);
		$industryvisit 								        = sanitize($_POST['txt_industryvisit'], SQL + HTML);

		$Invalid = "";
		$Invalid .= $Validation->check_blank("txt_require", $space, "Require Space");
		$Invalid .= $Validation->check_blank("txt_stall_area", $stall_area, "Stall Area");
		$Invalid .= $Validation->check_blank("txt_sponsorship_opportunity", $sponsorship_opportunity, "Sponsorship Opportunity");
		$Invalid .= $Validation->check_blank("txt_firstname", $fname, "First Name");
		$Invalid .= $Validation->check_blank("txt_lastname", $lname, "Last Name");
		$Invalid .= $Validation->check_blank("txt_company", $company, "Company");
		$Invalid .= $Validation->check_blank("txt_designation", $designation, "Designation");
		$Invalid .= $Validation->check_blank("txt_email", $email, "Email");
		//$Invalid .= $Validation->check_blank("txt_phone", $phone,"Phone");
		$Invalid .= $Validation->check_blank("txt_mobile", $mobile, "Mobile");
		$Invalid .= $Validation->check_blank("txt_City", $city,"city");
	    $Invalid .= $Validation->check_blank("txt_state", $state,"state");


		if ($Invalid) {
			$redirect = DOC_ROOT . "exhibitor-registration.php";
			echo "<script> alert('Exhibitor Details Not Register Successfully Please Try Again');setTimeout(function() { window.location = '$redirect'; } ); </script>";

			exit();
		} else {
			$exhibitorarray['exhibitiondetailid']                       = EXHIBITION_DETAILSID;
			$exhibitorarray['trak_form'] 			 			        = $utm_source;
			$exhibitorarray['trak_form_source'] 			 	        = $utm_medium;
			$exhibitorarray['space'] 			 						= $space;
			$exhibitorarray['stall_area'] 			 					= $stall_area;
			$exhibitorarray['sponsorship_oportunity'] 				    = $sponsorship_opportunity;
			$exhibitorarray['fname'] 			 						= $fname;
			$exhibitorarray['lname'] 			 						= $lname;
			$exhibitorarray['company_name'] 			 				= $company;
			$exhibitorarray['designation'] 			 					= $designation;
			$exhibitorarray['email'] 			 						= $email;
			$exhibitorarray['telno'] 			 						= $phone;
			//$exhibitorarray['mobile'] 			 						= $mobile;
			$exhibitorarray['mobile'] 			 						= $country_code.$mobile;
			$exhibitorarray['fromname'] 								= $fromname;
			$exhibitorarray['fromemail'] 								= $fromemail;
			$exhibitorarray['recipientname'] 							= $recipientname;
			$exhibitorarray['recipientemail'] 							= $recipientemail;
			$exhibitorarray['subject'] 									= $subject;
			$exhibitorarray['redirectpagename'] 						= $redirectpagename;
			$exhibitorarray['formname']         						= $formname;
			$exhibitorarray['domainname']       						= $domainname;
			$exhibitorarray['formtype']         						= $formtype;
			$exhibitorarray['entry_date']								= date("Y-m-d h:i:s");
			$exhibitorarray['country']         						    = $country;
			$exhibitorarray['city'] 			 				        = $city;
		    $exhibitorarray['state'] 			 				        = $state;
			$currentyear = date("Y");
			$exhibitorarray['exhibitionyear']							= $currentyear;
			//$exhibitorarray['industrybelong']         				= $industrybelong;
			//$exhibitorarray['industryvisit']         					= $industryvisit;

// 			print_r($exhibitorarray);         
//             die();                

// 			$addexhibitor = $allform->addallform($exhibitorarray);          
			// $addexhibitor= $AllTables->AddInfo($exhibitorarray,'mstcontacts');
			$addexhibitor = $AllTables->AddInfo($exhibitorarray, 'allsitesforminfo');
        
			if ($addexhibitor) {
				// $from_name = $fromname;
				// $from_email = $fromemail;
				// $to_name = $recipientname;
				// $to_email = 'forofficemails01@gmail.com,sahilmahadik300@gmail.com';
				// $subject = $subject;
				// $text_message = '';
				// $html_message = "A NEW REGISTRATION HAS BEEN RECEIVED FROM : $fname $lname OF Company : $company  ";
				// $attachment = '';

				// $sendmail = sendPHPMail($from_name, $from_email, $to_name, $to_email, $subject, $text_message, $html_message, $attachment);
				// echo "mail data : " . $sendmail;
				
				$redirect = DOC_ROOT . "exhibitor-registration.php";        
				echo "<script> alert('Exhibitor Details Register Successfully');setTimeout(function() { window.location = '$redirect'; } ); </script>";

				exit();
				
				// die();
				// 		require_once("include/email/sendMailScript.php");                     
			} else {
				$redirect = DOC_ROOT . "exhibitor-registration.php";
				echo "<script> alert('Exhibitor Details Not Register Successfully Please Try Again');setTimeout(function() { window.location = '$redirect'; } ); </script>";

				exit();
			}
		}
	}

	// }

} else {
	$utm_source = $_GET['utm_source']; 
	$utm_medium = $_GET['utm_medium'];
}

// $utm_medium = sanitize($_GET['utm_medium'], SQL+HTML);
include 'exhibitor-registration1.htm';
unset($_SESSION['codeerror']);
?>
<script>
	new WOW().init();
</script>

<?php include 'footer.php';
