The code for the recordset comes after the validation code.
change the code at lines 1 - 107:
<?php require_once('../Connections/PowerCMSConnection.php'); ?>
<?php require_once("../WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php require_once("../webassist/form_validations/wavt_scripts_php.php"); ?>
<?php require_once("../webassist/form_validations/wavt_validatedform_php.php"); ?>
<?php
if (isset($_POST["Insert"])) {
$WAFV_Redirect = "";
$_SESSION['WAVT_gallerycategoryInsert_609_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateNM($totalRows_check_repeat . "",-1,0,"",",.",true,1);
if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"gallerycategoryInsert_609");
}
}
?>
<?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;
}
}
mysql_select_db($database_PowerCMSConnection, $PowerCMSConnection);
$query_check_repeat = "SELECT * FROM gallery_category";
$check_repeat = mysql_query($query_check_repeat, $PowerCMSConnection) or die(mysql_error());
$row_check_repeat = mysql_fetch_assoc($check_repeat);
$totalRows_check_repeat = mysql_num_rows($check_repeat);$colname_check_repeat = "-1";
if (isset($_POST['category_name'])) {
$colname_check_repeat = (get_magic_quotes_gpc()) ? $_POST['category_name'] : addslashes($_POST['category_name']);
}
mysql_select_db($database_PowerCMSConnection, $PowerCMSConnection);
$query_check_repeat = sprintf("SELECT * FROM gallery_category WHERE category_name = %s", GetSQLValueString($colname_check_repeat, "text"));
$check_repeat = mysql_query($query_check_repeat, $PowerCMSConnection) or die(mysql_error());
$row_check_repeat = mysql_fetch_assoc($check_repeat);
$totalRows_check_repeat = mysql_num_rows($check_repeat);?><?php
// WA Application Builder Insert
if ((((isset($_POST["Insert"]))?$_POST["Insert"]:"") != "")) // Trigger
{
$WA_connection = $PowerCMSConnection;
$WA_table = "gallery_category";
$WA_sessionName = "gallery_category_category_id";
$WA_redirectURL = "gallery_category_Results.php";
$WA_keepQueryString = false;
$WA_indexField = "category_id";
$WA_fieldNamesStr = "category_name";
$WA_fieldValuesStr = "".((isset($_POST["category_name"]))?$_POST["category_name"]:"") ."";
$WA_columnTypesStr = "',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_PowerCMSConnection;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>
<?php
require_once( "../WA_SecurityAssist/Helper_PHP.php" );?>
<?php
require_once( "../WA_Globals/WA_Globals.php" ); ?>
<?php require_once( "../WA_CMS/WA_CMS.php" ); ?>
<?php
$query_CheckRepeat = "SELECT category_name FROM gallery_category";
$CheckRepeat = mysql_query($query_CheckRepeat, $PowerCMSConnection) or die(mysql_error());
$row_CheckRepeat = mysql_fetch_assoc($CheckRepeat);
$totalRows_CheckRepeat = mysql_num_rows($CheckRepeat);
?>
to:
<?php require_once('../Connections/PowerCMSConnection.php'); ?>
<?php require_once("../WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php require_once("../webassist/form_validations/wavt_scripts_php.php"); ?>
<?php require_once("../webassist/form_validations/wavt_validatedform_php.php"); ?>
<?php require_once( "../WA_SecurityAssist/Helper_PHP.php" ); ?>
<?php require_once( "../WA_Globals/WA_Globals.php" ); ?>
<?php require_once( "../WA_CMS/WA_CMS.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;
}
}
if (isset($_POST['category_name'])) {
$colname_check_repeat = (get_magic_quotes_gpc()) ? $_POST['category_name'] : addslashes($_POST['category_name']);
}
mysql_select_db($database_PowerCMSConnection, $PowerCMSConnection);
$query_check_repeat = sprintf("SELECT * FROM gallery_category WHERE category_name = %s", GetSQLValueString($colname_check_repeat, "text"));
$check_repeat = mysql_query($query_check_repeat, $PowerCMSConnection) or die(mysql_error());
$row_check_repeat = mysql_fetch_assoc($check_repeat);
$totalRows_check_repeat = mysql_num_rows($check_repeat);
?>
<?php
if (isset($_POST["Insert"])) {
$WAFV_Redirect = "";
$_SESSION['WAVT_gallerycategoryInsert_609_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateNM($totalRows_check_repeat . "",-1,0,"",",.",true,1);
if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"gallerycategoryInsert_609");
}
}
?>
<?php
// WA Application Builder Insert
if ((((isset($_POST["Insert"]))?$_POST["Insert"]:"") != "")) // Trigger
{
$WA_connection = $PowerCMSConnection;
$WA_table = "gallery_category";
$WA_sessionName = "gallery_category_category_id";
$WA_redirectURL = "gallery_category_Results.php";
$WA_keepQueryString = false;
$WA_indexField = "category_id";
$WA_fieldNamesStr = "category_name";
$WA_fieldValuesStr = "".((isset($_POST["category_name"]))?$_POST["category_name"]:"") ."";
$WA_columnTypesStr = "',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_PowerCMSConnection;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>