<?php

include("../includes/site_config.php");
include('../session_handler.inc');
include('../message.php');
require_once('../error.php');
require_once('../functions.php');
//if ($Sess_UserType != "A") {
//    exit;
//}

if (empty($_REQUEST['city_id'])) {
	echo "<script> window.location='$CONST_LINK_ROOT/admin/admin_geography.php'</script>";
    // header("Location: $CONST_LINK_ROOT/admin/admin_geography.php?PHPSESSID=".session_id());
    exit;
}

if($_POST[act]) {
    $sql_query = "UPDATE geo_city SET gct_name = '$_POST[gct_name]' WHERE gct_cityid = '$_POST[city_id]'";
//print_r($sql_query);
    mysql_query($sql_query, $link);
	echo "<script> window.location='$CONST_LINK_ROOT/admin/admin_geography.php'</script>";
    // header("Location: $CONST_LINK_ROOT/admin/admin_geography.php?PHPSESSID=".session_id());
    exit;
}

$query = "SELECT * FROM geo_city WHERE gct_cityid = '".$_REQUEST['city_id']."'";
$res = mysql_query($query);
$city = mysql_fetch_object($res);

# retrieve the template
$area = 'member';

?>
<?php include("include/header.php"); ?>
<table width="<?php print("$CONST_TABLE_WIDTH"); ?>" align="<?php print("$CONST_TABLE_ALIGN"); ?>" border="0" cellspacing="<?php print("$CONST_TABLE_CELLSPACING"); ?>" cellpadding="<?php print("$CONST_TABLE_CELLPADDING"); ?>">
  <tr>
    <td align="right">
      <?php //require_once("$CONST_INCLUDE_ROOT/user_status.inc.php");?>
    </td>
  </tr>
  <tr>
    <td class="pageheader"><?php echo GEOGRAPHY_SECTION_NAME ?></td>
  </tr>

  <tr>
    <td>
        <table border="0" width="100%" cellpadding="2" cellspacing="10">
            <form method="post" action="<?php echo $CONST_LINK_ROOT?>/admin/admin_cityedit.php<?php print("?PHPSESSID=".session_id()); ?>">
            <input type="hidden" name="city_id" value="<?=$_REQUEST['city_id']?>">
            <input type="hidden" name="act" value="save">
            <tr>
                <td colspan="3" align="left" valign="top" class="tdhead">&nbsp; </td>
            </tr>
            <tr align=center>
                <th align=right>
                    <?=SEARCH_CITY?>
                </th>
                <td align="left">
                    <input type="text" class="input" name="gct_name" value="<?=$city->gct_name?>">
                </td>
                <td></td>
            </tr>
            <tr>
                <td align="center"  colspan="3" class="tdfoot">
                    <input type=submit class=button name=SAVE value="<?=GENERAL_SAVE?>">
                    <input type=button class=button name=CANCEL value="Cancel" onClick="location.href='<?=$CONST_LINK_ROOT?>/admin/admin_geography.php<?php print("?PHPSESSID=".session_id()); ?>'">
                    </td>
                </tr>
                </form>
           </table>

        </td>
    </tr>

</table>
<?php mysql_close( $link ); ?>
<?php include("include/footer.php"); ?>