update trigger
What Update trigger should I use to have a page update without user interaction. I've used "Recordset not empty" but even though the data record is not empty, it will not update my record. If I put a submit button in the code and the user presses the button, it updates the record just fine. I do not want the user interacting with the update page.
<?php require_once('../../Connections/adminconn.php'); ?>
<?php require_once("../../WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php require_once( "../../WA_SecurityAssist/Helper_PHP.php" ); ?>
<?php
if (!WA_Auth_RulePasses("ChapterAdmins")){
WA_Auth_RestrictAccess("accessdenied.php");
}
?><?php
if (isset($_GET['Chapter_name']) && ($_GET['Chapter_name']) == "") {
$_GET['S_Chapter_name'] = "-1";
}
?>
<?php
if (isset($_GET['adminFirstName']) && ($_GET['adminFirstName']) == "") {
$_GET['adminFirstName'] = "-1";
}
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}
?>
<?php
if (!session_id()) session_start();
?>
<?php
$EntryDate = date("Y-m-d H:i");
$Admin = $_SESSION['adminFirstName'];
$ParamMemberID_WADAnoprcmembers = "-1";
if (isset($_GET['Member_ID'])) {
$ParamMemberID_WADAnoprcmembers = (get_magic_quotes_gpc()) ? $_GET['Member_ID'] : addslashes($_GET['Member_ID']);
}
mysql_select_db($database_adminconn, $adminconn);
$query_WADAnoprcmembers = sprintf("SELECT id, member_id, dues, ch_renewal_request_date, ch_processor, mc_process_date, mc_processor FROM dues WHERE year(mc_process_date) = $PastYear AND member_id = %s", GetSQLValueString($ParamMemberID_WADAnoprcmembers, "int"));
$WADAnoprcmembers = mysql_query($query_WADAnoprcmembers, $adminconn) or die(mysql_error());
$row_WADAnoprcmembers = mysql_fetch_assoc($WADAnoprcmembers);
$totalRows_WADAnoprcmembers = mysql_num_rows($WADAnoprcmembers);?>
<?php
// WA Application Builder Update
if (!($totalRows_WADAnoprcmembers == 0)) // Trigger
{
$WA_connection = $adminconn;
$WA_table = "dues";
$WA_redirectURL = "";
$WA_keepQueryString = false;
$WA_indexField = "id";
$WA_fieldNamesStr = "ch_renewal_request_date|ch_processor";
$WA_fieldValuesStr = "".((isset($_POST["Process_Date"]))?$_POST["Process_Date"]:"") ."" . "|" . "".((isset($_POST["Processed_by"]))?$_POST["Processed_by"]:"") ."";
$WA_columnTypesStr = "',none,NULL|',none,''";
$WA_comparisonStr = "=|=";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_where_fieldValuesStr = "".((isset($_POST["WADAUpdateRecordID"]))?$_POST["WADAUpdateRecordID"]:"") ."";
$WA_where_columnTypesStr = "none,none,NULL";
$WA_where_comparisonStr = "=";
$WA_where_fieldNames = explode("|", $WA_indexField);
$WA_where_fieldValues = explode("|", $WA_where_fieldValuesStr);
$WA_where_columns = explode("|", $WA_where_columnTypesStr);
$WA_where_comparisons = explode("|", $WA_where_comparisonStr);
$WA_connectionDB = $database_adminconn;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$updateParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WhereObj = WA_AB_generateWhereClause($WA_where_fieldNames, $WA_where_columns, $WA_where_fieldValues, $WA_where_comparisons );
$WA_Sql = "UPDATE `" . $WA_table . "` SET " . $updateParamsObj->WA_setValues . " WHERE " . $WhereObj->sqlWhereClause . "";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
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);
}
}
?>
<div id="form1_ProgressWrapper">
<form method="POST" name="form1" id="form1">
<input type="text" name="Process_Date" id="Process_Date" value="<?php echo(str_replace('"', '"', $EntryDate)); ?>" size="32" />
<input type="text" name="Processed_by" id="Processed_by" value="<?php echo $_SESSION['adminFirstName']; ?>" size="32" />
<input name="WADAUpdateRecordID" type="text" id="WADAUpdateRecordID" value="<?php echo(rawurlencode($row_WADAnoprcmembers['id'])); ?>" />
</form></div>
<?php
mysql_free_result($WADAnoprcmembers);
?>