<?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"] == "user_info")) {
  $updateSQL = sprintf("UPDATE members SET name=%s, username=%s, password=%s, email=%s WHERE id=%s",
                       GetSQLValueString($_POST['name'], "text"),
                       GetSQLValueString($_POST['username'], "text"),
                       GetSQLValueString($_POST['password'], "text"),
                       GetSQLValueString($_POST['email'], "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));
}

mysql_select_db($database_telmanik_press, $telmanik_press);
$query_user_info = "SELECT * FROM members";
$user_info = mysql_query($query_user_info, $telmanik_press) or die(mysql_error());
$row_user_info = mysql_fetch_assoc($user_info);
$totalRows_user_info = mysql_num_rows($user_info);
?>
<?php require("assets/wrapper/header.php"); ?>
<div align="center"><div class="mainlayout">
  <p>&nbsp;</p>
 <p><?php echo $translate->__('Update Administrator User Info');?></p>
 
 <form action="<?php echo $editFormAction; ?>" method="POST" name="user_info">
 
 <input type="hidden" name="id" id="id" value="<?php echo $row_user_info['id']; ?>"/>
 <?php echo $translate->__('Name:');?> <BR />
 <input name="name" type="text" value="<?php echo $row_user_info['name']; ?>" size="100" maxlength="255" /><br />
 <?php echo $translate->__('Username:');?> <BR />
 <input name="username" type="text" value="<?php echo $row_user_info['username']; ?>" size="100" maxlength="255" /><br />
<?php echo $translate->__('Password:');?> <BR />
 <input name="password" type="password" value="<?php echo $row_user_info['password']; ?>" size="100" maxlength="255" /><br />
 <?php echo $translate->__('Email Address:');?> <BR />
 <input name="email" type="text" value="<?php echo $row_user_info['email']; ?>" size="100" maxlength="255" /><br />
 <p>&nbsp;</p>
 <input name="submit" type="submit" value="<?php echo $translate->__('Update');?>" />
 <input type="hidden" name="MM_update" value="user_info" />
 </form>
 
 
 
 
 <p>&nbsp;</p>
   <p>&nbsp;</p>
 
 
 
</div>
</div>
<?php require("assets/wrapper/footer.php"); ?>
<?php
mysql_free_result($user_info);
?>
