Conditional Redirect in Update Statement
I've borrowed from DataAssist in order to update a customer record.
In DA, the Redirect URL would be the detail page of the record. I changed that to go to a page with a form and that worked just fine, but now I am trying to fine tune it because depending on the visit number, the client will get a different form.
Once I put in the conditional statement though, it seems to ignore it and instead defaults to the form appropriate for visit 1, even though my visitcount is being properly updated.
Here is my Update code.
<?php
// WA Application Builder Update
if (($_SERVER["REQUEST_METHOD"] == "POST") && (isset($_SERVER["HTTP_REFERER"]) && strpos(urldecode($_SERVER["HTTP_REFERER"]), urldecode($_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"])) > 0) && isset($_POST)) // Trigger
{
$WA_connection = $conn;
$WA_table = "clienttable";
if ($row_count['visitcount'] <= 1) { // Adv Conditional Region
$WA_redirectURL = "https://____/index.php?option=com_content&view=category&layout=blog&id=10&Itemid=38";
} // $row_count['visitcount'] <= 1
if ($row_count['visitcount'] >=2) { // Adv Conditional Region
$WA_redirectURL = "https://_____/index.php?option=com_content&view=category&layout=blog&id=23&Itemid=60";
} // $row_count['visitcount'] >=2
$WA_keepQueryString = false;
$WA_indexField = "eID";
$WA_fieldNamesStr = "emailaddr|visitcount|username|fname|lname";
$WA_fieldValuesStr = "".((isset($_POST["emailaddr"]))?$_POST["emailaddr"]:"") ."" . "|" . "".((isset($_POST["visitcount"]))?$_POST["visitcount"]:"") ."" . "|" . "".((isset($_POST["username"]))?$_POST["username"]:"") ."" . "|" . "".((isset($_POST["fname"]))?$_POST["fname"]:"") ."" . "|" . "".((isset($_POST["lname"]))?$_POST["lname"]:"") ."";
$WA_columnTypesStr = "',none,''|none,none,NULL|',none,''|',none,''|',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_conn;
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);
}
}
?>
I am sure it is just syntax, or ordering, but I am struggling. Any insight or assistance would be greatly appreciated.
Thanks,