﻿<?php require('system/login.php');  ?>
<?php require_once('../Connections/BE2.php'); ?>
<?php

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE adpage SET pdoc=%s, plink=%s, pdata=%s , pindex=%s , psignup=%s WHERE pid=%s",
                       GetSQLValueString($_POST['pdoc'], "text"),
                       GetSQLValueString($_POST['plink'], "text"),
					   GetSQLValueString($_POST['pdata'], "text"),
					   GetSQLValueString($_POST['pindex'], "int"),
					   GetSQLValueString($_POST['psignup'], "text"),
                       GetSQLValueString($_POST['pid'], "int"));

  mysql_select_db($database_BE2, $BE2);
  $Result1 = mysql_query($updateSQL, $BE2) or die(mysql_error());

  $updateGoTo = $_POST['url'];
  //header(sprintf("Location: %s", $updateGoTo)); 
  ?>
<script> location.replace("<?= $updateGoTo ; ?>"); </script>
<? 
}

$colname_Rt2 = "-1";
if (isset($_GET['id'])) {
  $colname_Rt2 = $_GET['id'];
}
mysql_select_db($database_BE2, $BE2);
$query_Rt2 = sprintf("SELECT * FROM adpage WHERE pid = %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="" method="post" name="form1" id="form1">
  <table align="center">
    <tr valign="baseline">
      <th width="146" align="right" nowrap="nowrap"><span class="font2">廣告分頁說明</span>:</th>
      <td width="281"><input type="text" name="pdoc" value="<?php echo htmlentities($row_Rt2['pdoc'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <th nowrap="nowrap" align="right"><span class="font2">廣告分頁連結</span>:</th>
      <td><input type="text" name="plink" value="<?php echo htmlentities($row_Rt2['plink'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <th nowrap="nowrap" align="right"><span class="font2">排列序</span>:</th>
      <td><input name="pindex" type="text" id="pindex" value="<?php echo  $row_Rt2['pindex'] ; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <th nowrap="nowrap" align="right"><span class="font2">連結報名表</span>:</th>
      <td><select name="psignup" id="psignup">
        <option value="N" <?php if (!(strcmp("Y", $row_Rt2['psignup']))) {echo "selected=\"selected\"";} ?>>N</option>
        <option value="Y" <?php if (!(strcmp("Y", $row_Rt2['psignup']))) {echo "selected=\"selected\"";} ?>>Y</option>
        <? if($myadmin){?>
        <? }?>
      </select></td>
    </tr>
    <tr valign="baseline">
      <th nowrap="nowrap" align="right"><span class="font2">資料模式</span>:</th>
      <td><select name="pdata" id="pdate">
        <option value="Y" <?php if (!(strcmp("Y", $row_Rt2['pdata']))) {echo "selected=\"selected\"";} ?>>廣告區塊模式</option>
        <option value="N" <?php if (!(strcmp("N", $row_Rt2['pdata']))) {echo "selected=\"selected\"";} ?>>HTML 文字編輯</option>
     <? // if($myadmin){   }  ?> 
     
     <option value="P" <?php if (!(strcmp("P", $row_Rt2['pdata']))) {echo "selected=\"selected\"";} ?>>php程式</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">&nbsp;</td>
      <td><input type="submit" value="更新記錄" /></td>
    </tr>
  </table>
  <input type="hidden" name="MM_update" value="form1" />
  <input type="hidden" name="pid" value="<?php echo $row_Rt2['pid']; ?>" />
  <input name="url" type="hidden" id="url" value="<? echo $_SERVER['HTTP_REFERER'];?>" />
</form>
 
<?php
mysql_free_result($Rt2);
?>
