<?php
include_once("class/class.MySQL.php");
include_once("class/class.Message.php");
$db	=new MySQL();
$msg = new messaging();
//test 
//$action = $_GET['action'];


$resultdsg = mysql_query("SELECT * FROM project_table where proj_name='$_POST[proj_name]' ");
$rowsd = mysql_num_rows($resultdsg);

$resultdsg_cnt = mysql_query("SELECT * FROM project_table  ");
$rowsd_cnts = mysql_num_rows($resultdsg_cnt);

if($rowsd > 0)
{

$vars['proj_name']='Already Saved Data';
echo '{"timing":'.json_encode($vars).'}';
}
else
{



	$data['proj_id'] = $_POST['proj_id'];
	$data['proj_name'] = $_POST['proj_name'];


	$db->Insert($data,'project_table');
	$pid = $db->LastInsertID();

/*$stges=$_POST['proj_stage'];

$data['stag_id'] = $_POST['proj_stage'];

foreach($stges as $pr_stage)
{
	$datas['mproj_id'] = $pid;
	$datas['stage_id'] = $pr_stage;

  if($pr_stage!='')
   {
	$db->Insert($datas,'project_stage');
	}
}

$result_stg = $db->fetchQuery("SELECT stage_id,id FROM project_stage");

foreach($result_stg as $result_st)
{
$data['stags'][$result_st['id']]=$result_st['stage_id'];
}
*/
$data['cntss']=$rowsd_cnts;
echo '{"timing":'.json_encode($data).'}';

}

//header('Location: add_project.php');
	

	
?>