<?php
session_start();
ob_start();
 include "../config/config.php"; 
 include "../config/function.php"; 
 
// print_r($_REQUEST);
 $private_key=get_privatekey($_SESSION['admin_name']);
 $request_from_server=$_SERVER['HTTP_REFERER'];
$this_server=$_SERVER['HTTP_HOST'];
if($request_from_server!=''){
	check_access_url($request_from_server,$this_server);
}

// echo $_SESSION['login_status'];echo "<br>";
// echo $_SESSION['private_key'];echo "<br>";
// echo $_SESSION['admin_name'];echo "<br>";

if($_SESSION['login_status']!='YES' || $_SESSION['private_key']!=$private_key || $_SESSION['private_key']=='' || $_SESSION['admin_name']=='')
{
    echo "Blank";
	header("Location:../AppLogin");
	exit();
}
else
{
    echo $member_name=strtoupper(text_input($_REQUEST['member_name']));
    echo $contact_no=text_input($_REQUEST['contact']);
    $member_user_id=text_input($_REQUEST['member_user_id']);
    $pan_no=strtoupper(text_input($_REQUEST['pan_no']));
    $aadhar_no=strtoupper(text_input($_REQUEST['aadhar_no']));
 
	if(strlen($member_name)>2 && strlen($contact_no)==10)
	{
	   
	    $reg_date=date("Y-m-d H:i:s");
    	echo $qry="Update tbl_memberreg set member_name='$member_name',contact='$contact_no',pan_no='$pan_no',aadhar_number='$aadhar_no' where member_user_id='$member_user_id'";
    	$result=mysqli_query($connection,$qry) or die(mysqli_error($connection));
    	if($result)
    	{
    	    
            $Up="Update tbl_memberreg set sponcer_name='$member_name' where  	sponcer_id='$member_user_id'";
            mysqli_query($connection,$Up) or die(mysqli_error($connection));
            
            $UpP="Update tbl_memberreg set promoter_name='$member_name' where  	promoter_id='$member_user_id'";
            mysqli_query($connection,$UpP) or die(mysqli_error($connection));
            
            mysqli_query($connection,"Update tbl_plot_registry_booking  set sponcer_name='$member_name' where sponcer_id='$member_user_id'");
            mysqli_query($connection,"Update tbl_member_income_dtails   set member_name='$member_name' where member_user_id='$member_user_id'");
            
            mysqli_query($connection,"Update  tbl_member_ledger    set member_name='$member_name' where member_user_id='$member_user_id'");
            
       		header("Location:../MemberReceipt?Asgct=$member_user_id");
    		
    	}
    	else
    	{
    		$msg="Something wrong........";
            header("Location:../EditAssociate?user_name=$member_user_id"); 
    	}
	}
	else
	{
		$msg="Something wrong........";
		header("Location:../EditAssociate?user_name=$member_user_id"); 
	}
	

}

?>