<?php
@session_start();
//require_once("db_conn_class.php");

require_once("webform_class.php");

//creating object of res info class

$app = new app();

/*$dbh = new db_conn();

$dbh->set_conn();*/

//==========================================================================

//retaining the value of the variables

if(isset($_POST['txtname']) && ($_POST['txtname'] != ""))

{

	$app->name =  str_replace("'"," ",$_POST['txtname']);

}

if(isset($_POST['contact']) && ($_POST['contact'] != ""))

{

	$app->contact =  str_replace("'"," ",$_POST['contact']);

}

if(isset($_POST['email']) && ($_POST['email'] != ""))

{

	$app->email =  str_replace("'"," ",$_POST['email']);

}

if(isset($_POST['dob']) && ($_POST['dob'] != ""))

{

	$app->dob =  str_replace("'"," ",$_POST['dob']);

}

if(isset($_POST['gender']) && ($_POST['gender'] != ""))

{

	$app->gender =  str_replace("'"," ",$_POST['gender']);

}

if(isset($_POST['country']) && ($_POST['country'] != ""))

{

	$app->country =  str_replace("'"," ",$_POST['country']);

}

if(isset($_POST['location']) && ($_POST['location'] != ""))

{

	$app->location =  str_replace("'"," ",$_POST['location']);

}


if(isset($_POST['form_name']) && ($_POST['form_name'] != ""))

{

	$app->form_name =  str_replace("'"," ",$_POST['form_name']);

}


if(isset($_POST['form_id']) && ($_POST['form_id'] != ""))

{

	$app->form_id =  str_replace("'"," ",$_POST['form_id']);

}




if(isset($_POST['cmbCourse']) && ($_POST['cmbCourse'] != ""))

{

	$app->course =  str_replace("'"," ",$_POST['cmbCourse']);

}

if(isset($_POST['comment']) && ($_POST['comment'] != ""))

{

	$app->comment =  str_replace("'"," ",$_POST['comment']);

}



//==========================================================================

//when save button is clicked



if(isset($_POST['submit_home']))

{	

    		

    //saving data into database

	$app->InsertData();	

	

	//for sending mail

	$app->SendMail();

	//$id = $_GET['id'];

	//echo $id;

	//return;

	@header("Location:thankyou.php");

}




if(isset($_POST['submit-newsletter']))

{	

    if($_SESSION['tb_captcha_key']!=$_POST['tb_captcha'])  

	//check whether stored in session value with the user submitted values

	{

		$_SESSION['CAPTCHA_ERROR'] = "Invalid Captcha Code.";

		

		header("Location:index.php");

	

	}else{					

    //saving data into database

	$app->InsertData3();	

	

	//for sending mail

	$app->SendMail3();
	
    $app->SendMailToCandidate3();

	//$id = $_GET['id'];

	//echo $id;

	//return;

	@header("Location:thankyou-newsletter.php");
	}

}





//==========================================================================


if(isset($_POST['submit-apply']))

{	

   if($_SESSION['tb_captcha_key']!=$_POST['tb_captcha'])  

	//check whether stored in session value with the user submitted values

	{

		$_SESSION['CAPTCHA_ERROR'] = "Invalid Captcha Code.";

		

		header("Location:apply.php");

	

	}else{					
		

    //saving data into database

	$app->InsertData2();	

	

	//for sending mail

	$app->SendMail2();

	//$id = $_GET['id'];

	//echo $id;

	//return;

	@header("Location:thankyou.php");
	}

}

//==========================================================================

if(isset($_POST['submit_all']))

{	

    		

    //saving data into database

	$app->InsertData_all();	

	

	//for sending mail

	$app->SendMail_all();

	$flag = 1;

	$msg ="Thank you for registering for the ACT's newsletter.";

	

	@header("Location:thankyou.php");

}


?>