<?

if (!isset($_SESSION)) //判斷是否已經開啟SESSION
{
session_start();
}//開起SESSION}
$id=$_SESSION['mAccount'];
$mid=$_SESSION['mId'];
require_once("../function.php");
check_login();

putenv("NLS_LANG=TRADITIONAL CHINESE_TAIWAN.AL32UTF8");



include("../db.php");
if(isset($_POST['action'])){
$action = $_POST['action'];
}
 if ($action == 'send'){

$name = $_POST['title'];
	//$email = isset($_REQUEST['email']) ? $_REQUEST['email'] : '';
	$message = $_POST['content'];
 $mId = $_POST['mId'];
 $rId = $_POST['rId'];
 $iId = $_POST['iId'];
$name=nl2br(htmlspecialchars($name));
$message=nl2br(htmlspecialchars($message));
	$date=date("Y-m-d H:i:s");
	
	
	
$str = oci_parse($conn,"INSERT INTO MESSAGE (IID,ISEND,IGET,ITITLE,ICONTENT,IREAD,IREPLY,ITIME,RID,REIID) VALUES 
      (MSG_ID.NEXTVAL,'$mid','$mId','$name','$message','1','0','$date','$rId','$iId')") or die('Insert error');
                 oci_execute($str);



  $str2 = oci_parse($conn,"update MESSAGE set IREPLY='1' where IID='$iId'") or die('Insert error');
                 oci_execute($str2);

	echo "傳送成功";
}
?>