<?php

$con = mysql_connect('localhost', 'root', 'Boom95z') or die(mysql_error());
mysql_select_db('orion9', $con);


$userIn = mysql_escape_string($_POST['userIn']);
$rFor = mysql_escape_string($_POST['rFor']);
$rCONID =  mysql_escape_string($_POST['rCONID']);
$rORGID =  mysql_escape_string($_POST['rORGID']);
$rTaskTitle =  mysql_escape_string($_POST['rTaskTitle']);
$rDesc =  mysql_escape_string($_POST['rDesc']);

$req_id  =  mysql_escape_string($_POST['req_id']);

 $userIn = '17';

echo $rFor;
if  ($req_id != '') // this is an existing item so just edit it
{
	if ($rFor == 'CL')
	{
		mysql_query("update client_requests set org_id=" . $rORGID, $con); 
		mysql_query("update client_requests set description='" . $rDesc . "'", $con); 
		mysql_query("update client_requests set task_type='" . $rTaskTitle . "'", $con); 
	}
	if ($rFor == 'CON')
	{
		echo "hreer";
		mysql_query("update requests set to_uid=" . $rCONID, $con); 
		mysql_query("update requests set description='" . $rDesc . "'", $con); 
		mysql_query("update requests set task_type='" . $rTaskTitle . "'", $con); 
	}
}
else
{
	if ($rFor == 'CL')
	{
		$insString = "INSERT INTO client_requests (int_id,org_id,date_created,description,task_type) 
		values (" . $userIn . "," . $rORGID . ", now(),'" . $rDesc . "','" . $rTaskTitle . "')";
		mysql_query($insString);
		
		echo $insString;
	}

	if ($rFor == 'CON')
	{
		 
		
		 $insString = "INSERT INTO requests (int_id,to_uid,date_created,description,task_type) 
		values (" . $userIn . "," . $rCONID . ", now(),'" . $rDesc . "','" . $rTaskTitle . "')";
		mysql_query($insString);
		
	  
	 
	}
}

mysql_close($con);

header('Location: tasks.php?typin=' . $rFor);

?>