<?php
session_start();

ini_set('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(1);
ini_set("log_errors", 1);
ini_set("error_log", "php-error.log");

date_default_timezone_set("UTC");

require_once('API_Config.php');

$obj = new API_Config;
$data = array();



if(!empty($_REQUEST['txtPrevID']))
{
	$data['refer_id'] =  $_REQUEST['txtPrevID'];

	$result = json_decode($obj->call_API("API_check_refer_id.php",$data));

    if($result->status)
	{
		if($_SESSION['refer_id'] == $result->user_info->sponsor_id)
		{
			unset($_SESSION['treeID']);
		}
		else
		{
			$_SESSION['treeID'] = $result->user_info->sponsor_id;
		}
	}
	
	else
		$_SESSION['treeID']=$_SESSION['refer_id'];


}


else
	$_SESSION['treeID']=$_REQUEST['txtNextID'];


header('Location: ../my-network.php');


?>