<?php
session_start();
ob_start();
 include "../config/config.php"; 
 include "../config/function.php"; 
 
 $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
{
   $sys_date=date("Y-m-d H:i:s");

$project_name=strtoupper(text_input($_REQUEST['project_name']));
$businessper=text_input($_REQUEST['businessper']);
//$rnd=str_shuffle("0123654789");
//echo $tmpFilePath = $_FILES['upload']['tmp_name']; echo "<br>"; 
$qry="Select * from tbl_prject_master where project_name='$project_name'";
$res=mysqli_query($connection,$qry);
if(mysqli_num_rows($res)==0)
{
// 	if ($tmpFilePath != ""){
// 		$newFilePath = "../../project/".$rnd. $_FILES['upload']['name'];
// 		$FilePath = $rnd. $_FILES['upload']['name'];		
// 			//Upload the file into the temp dir
// 		if(move_uploaded_file($tmpFilePath, $newFilePath))
// 		{

// 				echo $str="Insert Into tbl_prject_master(project_name,upload_map)value('$project_name','$FilePath')"; 
// 				mysqli_query($connection,$str);
// 		}
// 	}
// 	else
// 	{
		
// 	}
    echo $str="Insert Into tbl_prject_master(project_name,upload_map,businessper)value('$project_name','',$businessper)"; 
		mysqli_query($connection,$str);
	 $msg="Project Add Successfully....";
}
else
{
	$msg="Project All Ready Exist In Record";
}
} 
header("Location:../AddNewProject");
?>