<?

if (!isset($_SESSION)) //判斷是否已經開啟SESSION
{
session_start();}//開起SESSION
putenv("NLS_LANG=TRADITIONAL CHINESE_TAIWAN.AL32UTF8");
$mAccount=$_SESSION['mAccount'];
$mid=$_SESSION['mId'];
if($mid!=''){
?>





<?
require_once("../db.php");

function ChangWord($NewWord){

		// 將 enter 符號換為 <br>
    		$NewWord=str_replace("<br />","",$NewWord);

		// 將 [']+ 符號,換為 `
   		$NewWord=ereg_replace("[']+", "`", $NewWord);
		return $NewWord;
 	}
	


//$rTitle=$_POST['rTitle'];
$rPlace=$_POST['rPlace'];

$rTime_a=$_POST['rTime_a'];
$rTime_b=$_POST['rTime_b'];
$rTime = $rTime_a."-".$rTime_b;

$rDate=$_POST['rDate'];
$rElse=$_POST['rElse'];
$rPhone=$_POST['rPhone'];
$rEmail=$_POST['rEmail'];
//$rMsn=$_POST['rMsn'];
$aId=$_POST['aId'];
$mId=$_POST['mId'];
$rLimit = $_POST['rLimit'];
$rPotime=date("Y-m-d");






/*------------------空白判斷-----------------------*/
if(empty($rPlace))
{
	echo "<html>
        	<head>
        	<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
        	</head>
        	<body><script>";
	echo "alert(\"請輸入揪團集合地點!!\");";
	echo "history.go(-1)";
	echo "</script></body>
        	</html>";
}
else if(empty($rTime_a)||empty($rTime_b))
{
	echo "<html>
        	<head>
        	<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
        	</head>
        	<body><script>";
	echo "alert(\"請選擇揪團集合時間!\");";
	echo "history.go(-1)";
	echo "</script></body>
        	</html>";
}
else if(empty($rPhone))
{
	echo "<html>
        	<head>
        	<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
        	</head>
        	<body><script>";
	echo "alert(\"請輸入您的聯絡資訊!!\");";
	echo "history.go(-1)";
	echo "</script></body>
        	</html>";
}
else
{

 $rElse=nl2br(htmlspecialchars($rElse));
// $rTitle=nl2br(htmlspecialchars($rTitle));
$rPlace=nl2br(htmlspecialchars($rPlace));
$rTime_a=nl2br(htmlspecialchars($rTime_b));
$rTime=nl2br(htmlspecialchars($rTime));
$rDate=nl2br(htmlspecialchars($rDate));
$rPhone=nl2br(htmlspecialchars($rPhone));
$rEmail=nl2br(htmlspecialchars($rEmail));
//$rMsn=nl2br(htmlspecialchars($rMsn));
$rLimit=nl2br(htmlspecialchars($rLimit));


$str = oci_parse($conn,"INSERT INTO RAISE (RID,RPLACE,RTIME,RDATE,RELSE,RPHONE,REMAIL,MID,AID,RLIMIT,RLIMIT_1,RPOTIME) VALUES 
		(RAISE_ID.NEXTVAL,'$rPlace','$rTime','$rDate','$rElse','$rPhone','$rEmail','$mId','$aId','$rLimit','0','$rPotime')") or die('Insert error');

	
}

oci_execute($str);







	$sql = oci_parse($conn,"SELECT RAISE_ID.CURRVAL FROM DUAL") or die('Insert error');
oci_execute($sql);
$row=oci_fetch_array($sql);
$rId=$row[0];

echo "<html>
        	<head>
        	<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
        	</head>
        	<body><script>";
			echo "alert(\"揪團發佈成功\");";
			echo "location.href=\"show_raise_detail.php?rId=$rId\" ";
			echo "</script></body>
        	</html>";
			
?>


 <?
}else{echo "請先登入";}
?>





