Ok, I've obviously made a mistake. It's not working, but no errors either, but it is allowing duplicates to be written.
<?php
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;
}
}
mysql_select_db($database_SQL_TABLE, $SQL_TABLE);
$query_getEmails = "SELECT emailaddress FROM emails WHERE emailaddress = '".$_POST['emailaddress']."'";
$getEmails = mysql_query($query_getEmails, $SQL_TABLE) or die(mysql_error());
$row_getEmails = mysql_fetch_assoc($getEmails);
$totalRows_getEmails = mysql_num_rows($getEmails);
?>
<?php
if (isset($_POST["Insert"])) {
$WAFV_Redirect = "";
$_SESSION['WAVT_addemailaddresses_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateAN($row_getEmails['emailaddress'] ='0' . "",true,true,true,true,"",true,1);
if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"addemailaddresses");
}
}
?>
<?php
$WADbSearch1_DefaultWhere = "WHERE 0=0";
if (!session_id()) session_start();
if (isset($_POST["Insert"])) {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//keyword array declarations
//comparison list additions
$WADbSearch1->addComparison("emailaddress","".((isset($_POST["emailaddress"]))?$_POST["emailaddress"]:"") ."","AND","=",0);
//save the query in a session variable
if (1 == 1) {
$_SESSION["WADbSearch1_add_emailaddresses"]=$WADbSearch1->whereClause;
}
}
else {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//get the filter definition from a session variable
if (1 == 1) {
if (isset($_SESSION["WADbSearch1_add_emailaddresses"]) && $_SESSION["WADbSearch1_add_emailaddresses"] != "") {
$WADbSearch1->whereClause = $_SESSION["WADbSearch1_add_emailaddresses"];
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
$WADbSearch1->whereClause = str_replace("\\''", "''", $WADbSearch1->whereClause);
$WADbSearch1whereClause = '';
?>
<?php
if (isset($_POST["Insert"])) // Trigger
{
$WA_connection = $SQL_TABLE;
$WA_table = "emails";
$WA_sessionName = "WADA_Insert_emails";
$WA_redirectURL = "add_emailaddresses.php";
$WA_keepQueryString = false;
$WA_indexField = "recid";
$WA_fieldNamesStr = "fname|lname|address|city|state|zip|emailaddress|html|active";
$WA_fieldValuesStr = "".((isset($_POST["fname"]))?$_POST["fname"]:"") ."" . "|" . "".((isset($_POST["lname"]))?$_POST["lname"]:"") ."" . "|" . "".((isset($_POST["address"]))?$_POST["address"]:"") ."" . "|" . "".((isset($_POST["city"]))?$_POST["city"]:"") ."" . "|" . "".((isset($_POST["state"]))?$_POST["state"]:"") ."" . "|" . "".((isset($_POST["zip"]))?$_POST["zip"]:"") ."" . "|" . "".((isset($_POST["emailaddress"]))?$_POST["emailaddress"]:"") ."" . "|" . "".((isset($_POST["html"]))?$_POST["html"]:"") ."" . "|" . "".((isset($_POST["active"]))?$_POST["active"]:"") ."";
$WA_columnTypesStr = "',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_SQL_TABLE;
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);
}
}
?>