<?php require('system/login.php');  ?>
<?php require_once('../Connections/BE2.php'); ?>
<?php

if($_SESSION['login_lv']<4){ exit;}


if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {

           $updateSQL = sprintf("UPDATE fixnews SET title=%s, idate=%s, doc=%s, link=%s ,wflag=%s WHERE id=%s",
                       GetSQLValueString($_POST['title'], "text"),
					   GetSQLValueString($_POST['idate'], "text"),
                       GetSQLValueString($_POST['doc'], "text"),
                       GetSQLValueString($_POST['link'], "text"),
					   GetSQLValueString($_POST['wflag'], "text"),
                       GetSQLValueString($_POST['id'], "int"));

  mysql_select_db($database_BE2, $BE2);
  $Result1 = mysql_query($updateSQL, $BE2) or die(mysql_error());
 //echo $updateSQL;
 $updateGoTo = "main.php?act=pro_welcome";
	//  header(sprintf("Location: %s", $updateGoTo));
	   ?>
    <script type="text/javascript">
   <!--
   alert('資料已更新存檔... \n');location.href='<? echo $updateGoTo;?>';  
   //-->
   </script> <?
	  
	  
	  
	  
}

$colname_Rt2 = "-1";
if (isset($_GET['id'])) {
  $colname_Rt2 = $_GET['id'];
}
mysql_select_db($database_BE2, $BE2);
$query_Rt2 = sprintf("SELECT * FROM fixnews WHERE id = '%s'", GetSQLValueString($colname_Rt2, "int"));
$Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error());
$row_Rt2 = mysql_fetch_assoc($Rt2);
$totalRows_Rt2 = mysql_num_rows($Rt2);
?>
<form action="" enctype="multipart/form-data" method="post" name="form1" id="form1">
  <input name="id" type="hidden" id="id" value="<?php echo $row_Rt2['id']; ?>" />
  <table width="65%" align="center">
    <tr valign="baseline">
      <td align="right" valign="top">&nbsp;</td>
      <td align="right" valign="top">&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td align="right" valign="top">&nbsp;</td>
      <td align="left" valign="top">&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <th width="9%" align="right" valign="top" nowrap="nowrap">標題/</th>
      <td width="91%" valign="middle"><input type="text" name="title" value="<?php echo $row_Rt2['title']; ?>" size="50" />
      <input type="hidden" name="link" value="<?php echo $row_Rt2['link']; ?>" size="50" /></td>
    </tr>
    <tr valign="baseline">
      <th align="right" valign="top" nowrap="nowrap">發佈日期/</th>
      <td valign="middle" class="font3"><input name="idate" type="text" id="idate" value="<? echo $row_Rt2['idate'] ;?>" size="12" class="seldate" />
        例 2010-01-31 
        <input type="hidden" name="tmpdate" id="tmpdate" /></td>
    </tr>
    <tr valign="baseline">
      <th align="right" valign="top" nowrap="nowrap">內文/</th>
      <td><textarea name="doc" cols="50" rows="12" id="doc"><?php echo $row_Rt2['doc']; ?></textarea></td>
    </tr>
    <tr valign="baseline">
      <td height="40" align="center" valign="middle" nowrap="nowrap"><label for="select"></label></td>
      <td align="center" valign="middle"><? if($_SERVER['REMOTE_ADDR']=="220.130.43.121"){ ?>
      <select name="wflag" id="select">
        <option value="Y">Y</option>
        <option value="N" selected="selected">N</option>
      </select> <? } else { ?>
      <input type="hidden" name="wflag" id="wflag" />
      <? }?>
      <input type="submit" value="更新資料" /></td>
    </tr>
  </table>
  <input type="hidden" name="MM_update" value="form1" />
</form>
<div id="showcalendardiv" style="display:none" ><? // include "free_date.php" ;?></div>
<?php
mysql_free_result($Rt2);
?>
