<?

include ('conn.php');
if($mod==ann){
$classuser=$HTTP_COOKIE_VARS["class_username"];
$query="select stat from classuser where username='$classuser'";
$result=mysql_db_query("$dbname",$query);
$r=mysql_fetch_array($result);
$stat=$r["stat"];
if($stat!=1){
echo "你不是管理员！";exit;}
$query="select classname,adminemail,announcement from classconfig";
$result=mysql_db_query("$dbname",$query);
$r=mysql_fetch_array($result);
$announcement=$r["announcement"];
$classname=$r["classname"];
$adminemail=$r["adminemail"];
?><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>编辑公告</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>

<table width="380" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td><form name="form1" method="post" action="<? echo "$PHP_SELF?mod=saveann"; ?>">
        <p align="center"> 
          <textarea name="ann" cols="30" rows="8" id="ann"><? echo $announcement; ?></textarea>
          <br>
          班 级 名 称<input name="classname" type="text" value="<? echo"$classname";?>">
          <br>
          管理员信箱 <input name="adminemail" type="text" value="<? echo"$adminemail";?>">
        </p>
        <p align="center"> 
          <input type="submit" name="Submit" value="改好了">
        
          
        </p>
      </form></td>
  </tr>
</table>
<? } if($mod==saveann){
$ann=$HTTP_POST_VARS["ann"];
$classname=$HTTP_POST_VARS["classname"];
$adminemail=$HTTP_POST_VARS["adminemail"];
$query="update classconfig set announcement='$ann',classname='$classname',adminemail='$adminemail'";
$result=mysql_db_query("$dbname",$query);
if($result==1)
  {
   echo"成功更改!";
   echo"<br>刷新首页才能看到更新后的内容！";
   ?>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>修改公告</title>
<meta http-equiv=Refresh content="2; url=javascript:window.close()">
<link href="css.css" rel="stylesheet" type="text/css">
<? }else {echo"更新不成功，出错了！";}
} ?>
<?php require("bottom.php"); ?>