<?php require_once('../Connections/tripoli.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO category (id_cat, title, active_fg) VALUES (%s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['id_cat'], "int"),
GetSQLValueString($HTTP_POST_VARS['title'], "text"),
GetSQLValueString(isset($HTTP_POST_VARS['active_fg']) ? "true" : "", "defined","'Y'","'N'"));
mysql_select_db($database_tripoli, $tripoli);
$Result1 = mysql_query($insertSQL, $tripoli) or die(mysql_error());
$insertGoTo = "admincategory.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
$col_category = "0";
if (isset($HTTP_GET_VARS['id_cat'])) {
$col_category = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['id_cat'] : addslashes($HTTP_GET_VARS['id_cat']);
}
mysql_select_db($database_tripoli, $tripoli);
$query_category = sprintf("SELECT * FROM category WHERE category.id_cat=%s", $col_category);
$category = mysql_query($query_category, $tripoli) or die(mysql_error());
$row_category = mysql_fetch_assoc($category);
$totalRows_category = mysql_num_rows($category);
?>