<?php
 	session_start();
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);	

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

	
	
	$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));
	
	
	include("connect.php");
include("mylibrary.php");
	//$umid=$_SESSION['umid'];
	
	 $umid = $_POST['umid'];
	 
	
	 $eve23 = "select * from res_contact_master where clinkid=$umid and clinktype='Agent'";
	$re23 = mysqli_query($conn, $eve23);
	while($rt23 = mysqli_fetch_assoc($re23))
	{
		$scaddress1=checkvalidstring($rt23['caddress1']);
		$scaddress2=checkvalidstring($rt23['caddress2']);
		$sccountry=$rt23['ccountry'];
		$scstate=$rt23['cstate'];
		$sccity=$rt23['ccity'];
		$scarea=$rt23['carea'];
		$scpostalcode=checkvalidstring($rt23['cpostalcode']);
		$sccompanyname=checkvalidstring($rt23['ccompanyname']);
	}
	$scontactname=checkvalidstring ($_POST['scontactname']);
	
	
	$scmiddlename=checkvalidstring ($_POST['scmiddlename']);
	
	
	$scsurname=checkvalidstring ($_POST['scsurname']);
	
	
		$scontactnumber=checkvalidstring ($_POST['scontactnumber']);
	$scontactnumber=checkvalidstring ($scontactnumber);
	$smobilecode=$_POST['smobilecode'];
	$scontactnumber=$smobilecode."".$scontactnumber;
	$scmobilenumber=checkvalidstring ($_POST['scmobilenumber']);
	
	$shomemobilecode=$_POST['shomemobilecode'];
	$scmobilenumber=$shomemobilecode."".$scmobilenumber;
	$scontactemail=checkvalidstring ($_POST['scontactemail']);
	
	$scaltenateemail=checkvalidstring ($_POST['scaltenateemail']);
	
	$scontactdepartmnet=checkvalidstring ($_POST['scontactdepartmnet']);
	
	$scposition=checkvalidstring ($_POST['scposition']);
	
	$scremarks=checkvalidstring ($_POST['scremarks']);
	
	
	
	$scmsgappname=checkvalidstring ($_POST['scmsgappname']);
	
	$scmsgappid=checkvalidstring($_POST['scmsgappid']);
	
	
	$scvideoappname=checkvalidstring ($_POST['scvideoappname']);
	
	
	$scvideoappid=checkvalidstring($_POST['scvideoappid']);
	
	 $eve3 = "INSERT INTO res_contact_master (contactname, contactemail,contactnumber,cmobilenumber,contactdepartmnet,cposition,cremarks,caltenateemail,caddress1,caddress2,ccountry,cstate,ccity,carea,cpostalcode,cmiddlename,csurname,cmsgappname,cmsgappid,cvideoappname,cvideoappid,ccompanyname,clinktype,clinkid) VALUES('$scontactname','$scontactemail','$scontactnumber','$scmobilenumber','$scontactdepartmnet','$scposition','$scremarks','$scaltenateemail','$scaddress1','$scaddress2','$sccountry','$scstate','$sccity','$scarea','$scpostalcode','$scmiddlename','$scsurname','$scmsgappname','$scmsgappid','$scvideoappname','$scvideoappid','$sccompanyname','AgentStaff','$umid')";
			
		
		$re3 = mysqli_query($conn, $eve3);
			
		
		
		
		
		
		header('Location: agentdetail.php?id='.$umid);
	
?>