<?php
require_once("../global/checkuser2.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="REFRESH" content="2; URL=index.php" />
<title>处理函数</title>
</head>

<body>
<?php
require_once("../global/connect.php");
if("add"==$_GET["mod"]){
$date=date("Y-m-d");
if(mysql_num_rows(mysql_query("select * from news where name='$_POST[name]' and date='$date'"))==0){
$beizhu=strip_tags($_POST["beizhu"]);
$baojia=strip_tags($_POST["baojia"]);
$leixing="";
$fangxiang="";
foreach($_POST["leixing"] as $a => $b){
if($a!=count($_POST["leixing"])-1)
$leixing .=$b.",";
else
$leixing .=$b;
}
foreach($_POST["fangxiang"] as $a => $b){
if($a!=count($_POST["fangxiang"])-1)
$fangxiang .=$b.",";
else
$fangxiang .=$b;
}
$sql="INSERT INTO report (date,name,leixing,banmian,color,baojia,meiti,fangxiang,zhekou,beizhu) VALUES ('$date','$_POST[name]','$leixing','$_POST[banmian]','$_POST[color]','$_POST[baojia]','$_POST[meiti]','$fangxiang','$_POST[zhekou]','$_POST[beizhu]')";
mysql_query($sql);
echo "操作成功!2秒后自动返回...";
}
else
echo "操作失败!".$_POST["name"]."在".$date."的数据已存在";
}
if("delete"==$_GET["mod"]){
mysql_query("delete from report where id=$_GET[id]");
echo "操作成功!2秒后自动返回...";
}
echo "<script>setTimeout('parent.location.reload()',2000);</script>";
?>
</body>
</html>
