<?php require_once('../Connections/telmanik_press.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE pages SET page_name=%s, page_title=%s WHERE id=%s",
                       GetSQLValueString($_POST['page'], "text"),
                       GetSQLValueString($_POST['title'], "text"),
                       GetSQLValueString($_POST['id'], "int"));

  mysql_select_db($database_telmanik_press, $telmanik_press);
  $Result1 = mysql_query($updateSQL, $telmanik_press) or die(mysql_error());

  $updateGoTo = "success.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

$colname_pages = "-1";
if (isset($_GET['id'])) {
  $colname_pages = $_GET['id'];
}
mysql_select_db($database_telmanik_press, $telmanik_press);
$query_pages = sprintf("SELECT * FROM pages WHERE id = %s", GetSQLValueString($colname_pages, "int"));
$pages = mysql_query($query_pages, $telmanik_press) or die(mysql_error());
$row_pages = mysql_fetch_assoc($pages);
$totalRows_pages = mysql_num_rows($pages);
 session_start(); ?>
<?php require("assets/wrapper/header.php"); ?>



<div id="editload">
<BR />
<p></p>
<form action="<?php echo $editFormAction; ?>" id="form1" name="form1" method="POST">
 
 
       
      <input name="id" type="hidden" id="id" value="<?php echo $row_pages['id']; ?>" />
      
        
     <div id="edithead"> Page 
       <input name="page" type="text" id="page" value="<?php echo $row_pages['page_name']; ?>" size="100" maxlength="255" />
    <p>  Title
    <input name="title" type="text" id="title" size="100" maxlength="255" value="<?php echo $row_pages['page_title']; ?>"/></p></div>
 
      
    
  <p>&nbsp;  </p>
  <p>
    <input type="submit" name="idupdate" id="idupdate" value="confirm Update" />
  </p>
  <input type="hidden" name="MM_update" value="form1" />
</form>
</div>
  <p>&nbsp;  </p>
    <p>&nbsp;  </p>
      <p>&nbsp;  </p>
<?php require("assets/wrapper/footer.php"); ?>
<?php
mysql_free_result($pages);
?>
