<?php
 	session_start(); 

	if(!isset($_SESSION['tulsilogin']))
	{
		header('Location: index.php');
		return;
	}



$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));
	
	
	include("connect.php");

	
	//$contactname=$_POST['contactname'];
	$contactname=str_replace ("'","\'",$_POST['contactname']);
	$contactname=str_replace ('"','\"',$contactname);
	
	$cmiddlename=str_replace ("'","\'",$_POST['cmiddlename']);
	$cmiddlename=str_replace ('"','\"',$cmiddlename);
	
	$csurname=str_replace ("'","\'",$_POST['csurname']);
	$csurname=str_replace ('"','\"',$csurname);
	
		$contactnumber=str_replace ("'","\'",$_POST['contactnumber']);
	$contactnumber=str_replace ('"','\"',$contactnumber);
	$mobilecode=$_POST['mobilecode'];
	$contactnumber=$mobilecode."".$contactnumber;
	$cmobilenumber=str_replace ("'","\'",$_POST['cmobilenumber']);
	$cmobilenumber=str_replace ('"','\"',$cmobilenumber);
	$homemobilecode=$_POST['homemobilecode'];
	$cmobilenumber=$homemobilecode."".$cmobilenumber;
	$contactemail=str_replace ("'","\'",$_POST['contactemail']);
	$contactemail=str_replace ('"','\"',$contactemail);
	$caltenateemail=str_replace ("'","\'",$_POST['caltenateemail']);
	$caltenateemail=str_replace ('"','\"',$caltenateemail);
	$contactdepartmnet=str_replace ("'","\'",$_POST['contactdepartmnet']);
	$contactdepartmnet=str_replace ('"','\"',$contactdepartmnet);
	$cposition=str_replace ("'","\'",$_POST['cposition']);
	$cposition=str_replace ('"','\"',$cposition);
	$cremarks=str_replace ("'","\'",$_POST['cremarks']);
	$cremarks=str_replace ('"','\"',$cremarks);
	
	$caddress1=str_replace ("'","\'",$_POST['caddress1']);
	$caddress1=str_replace ('"','\"',$caddress1);
	
	$caddress2=str_replace ("'","\'",$_POST['caddress2']);
	$caddress2=str_replace ('"','\"',$caddress2);
	
	$ccountry=str_replace ("'","\'",$_POST['ccountry']);
	$ccountry=str_replace ('"','\"',$ccountry);
	$cpostalcode=str_replace ("'","\'",$_POST['cpostalcode']);
	$cpostalcode=str_replace ('"','\"',$cpostalcode);
	
	$cmsgappname=str_replace ("'","\'",$_POST['cmsgappname']);
	$cmsgappname=str_replace ('"','\"',$cmsgappname);
	
	$csubcategory=str_replace ("'","\'",$_POST['csubcategory']);
	$csubcategory=str_replace ('"','\"',$csubcategory);
	
	$cmsgappid=$_POST['cmsgappid'];
	
	
	$cvideoappname=str_replace ("'","\'",$_POST['cvideoappname']);
	$cvideoappname=str_replace ('"','\"',$cvideoappname);
	
	$cvideoappid=$_POST['cvideoappid'];
	
	
	$ccompanyname=str_replace ("'","\'",$_POST['ccompanyname']);
	$ccompanyname=str_replace ('"','\"',$ccompanyname);
	
	$cstate=str_replace ("'","\'",$_POST['cstate']);
	$cstate=str_replace ('"','\"',$cstate);
	
	$ccity=$_POST['ccity'];
	
	
	
	
	
		
		
		 $eve1 = "INSERT INTO res_contact_master (contactname, contactemail,contactnumber,cmobilenumber,contactdepartmnet,cposition,cremarks,caltenateemail,caddress1,caddress2,ccountry,cstate,ccity,cpostalcode,cmiddlename,csurname,cmsgappname,cmsgappid,cvideoappname,cvideoappid,ccompanyname,csubcategory) VALUES('$contactname','$contactemail','$contactnumber','$cmobilenumber','$contactdepartmnet','$cposition','$cremarks','$caltenateemail','$caddress1','$caddress2','$ccountry','$cstate','$ccity','$cpostalcode','$cmiddlename','$csurname','$cmsgappname','$cmsgappid','$cvideoappname','$cvideoappid','$ccompanyname','$csubcategory')";
		
		$re1 = mysqli_query($conn, $eve1);
		
			
	$_SESSION['msg'] = "Record saved successfully";
	
	if(isset($_POST['exit'])){
	header('Location: contact.php');
	}else{
		header('Location: contactadd.php');
	}
			
	
?>