Help with loop to reset a field after form submission
Hope someone might be able to help with this. Its something that I'm pretty certain was working, but now no longer seems to be.
Basically the set up is that a site owner can select a number of contact using checkboxes to send an email out to people. (So its using Universal Email as well.)
The way its set up is that there's a database field 'Email List' and the site owner selected the contacts, setting that field to Y, and then the email is sent to everyone with Email List=Y.
And then once the email has been sent, there's a button which should reset the value of 'Email List' back to N, so that each time the system is used, its with a fresh list of contacts.
The problem is that the reset doesn't seem to be working anymore.
I have attached the page that should be doing this - not sure what's happened, as I'm sure it did work in the past.
The code that should be doing it is:
<?php
// WA DataAssist Multiple Updates
if ($_SERVER["REQUEST_METHOD"] == "POST") // Trigger
{
if (!session_id()) session_start();
$WA_loopedIDField = array("WADA_RepeatID_CandidateID");
$WA_connection = $connSearchTechUK;
$WA_table = "Candidates";
$WA_redirectURL = "admin.php";
$WA_keepQueryString = false;
$WA_indexField = "CandidateID";
$WA_fieldNamesStr = "EmailList";
$WA_columnTypesStr = "none,'Y','N'";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_connSearchTechUK;
$WA_multipleUpdateCounter = 0;
mysql_select_db($WA_connectionDB, $WA_connection);
while (WA_AB_checkLoopedFieldsNotBlank($WA_loopedIDField, $WA_multipleUpdateCounter)) {
$WA_fieldValuesStr = "".$row_rsEmail['N'] ."";
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_where_fieldValuesStr = WA_AB_getLoopedFieldValue($WA_loopedIDField[0], $WA_multipleUpdateCounter);
$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);
$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());
$WA_multipleUpdateCounter++;
}
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);
}
}
?>
Thanks.