<?

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

include("../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'];
    $message=nl2br(htmlspecialchars($message));
	$name=nl2br(htmlspecialchars($name));
	$date=date("Y-m-d H:i:s");
	if($rid!=''){
	
	$str = oci_parse($conn,"INSERT INTO MESSAGE (IID,ISEND,IGET,ITITLE,ICONTENT,IREAD,IREPLY,ITIME,RID) VALUES 
      (MSG_ID.NEXTVAL,'$mid','$mId','$name','$message','1','0','$date','$rId')") or die('Insert error');
oci_execute($str);
	}else{
	
	
	$str = oci_parse($conn,"INSERT INTO MESSAGE (IID,ISEND,IGET,ITITLE,ICONTENT,IREAD,IREPLY,ITIME,RID) VALUES 
      (MSG_ID.NEXTVAL,'$mid','$mId','$name','$message','1','0','$date','0')") or die('Insert error');
oci_execute($str);
	}
	
	

	echo "傳送完成";

}
?>

