<?

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

require_once ("../function.php");
check_login();

include("../db.php");

$act=$_POST['act'];
if($act=='del'){
$qId=$_POST['qId'];
mysql_query("delete from qanda where qId='$qId'");
}
if($act=='rep'){
$qId=$_POST['qId'];
$rId=$_POST['rId'];
$ccont=$_POST['rContent'];
  $rTime= date("Y-m-d H:i:s");
mysql_query("insert into reply (rContent,rTime,rId,qId) values ('$ccont','$rTime','$rId','$qId')");

echo "<html>
        	<head>
        	<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
        	</head>
        	<body><script>";
	echo "alert(\"回覆完成\");";
	echo "location.href=\"ad_main.php?rId=$rId\" ";
	echo "</script></body>
        	</html>";


}

if($act=='reupd'){
$qId=$_POST['qId'];
$rId=$_POST['rId'];
$ccont=$_POST['rContent'];
  $rTime= date("Y-m-d H:i:s");
mysql_query("update reply set rContent='$ccont',rTime='$rTime',rId='$rId',qId='$qId' where qId='$qId'");

echo "<html>
        	<head>
        	<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
        	</head>
        	<body><script>";
	echo "alert(\"修改完成\");";
	echo "location.href=\"ad_main.php?rId=$rId\" ";
	echo "</script></body>
        	</html>";


}

?>		