You need to take the returns out of the loop. The loop will only be evaluated once, then it\'ll either return the error message or true. Try this:
for ($j=1;$j<$newMail;$j++)
{
$row[$j] = mysql_fetch_array($result[$j]);
If ($row[\"email_address\".$j.\"\"] == $email_address[$j])
{
$ErrorString .= \"Email Address #\".$j.\" already exists. Please choose another.<BR>\n\";
$errormsg .= $ErrorString;
}
}
if(strlen($errormsg) > 0)
{
return $errormsg;
}
else
{
return true;
}
You could make it even better by defining $errormsg as true in the beginning of your script. Then you could remove the check to see if there is anything in it and just return it, whatever it is.
function verifyAddress()
{
$errormsg = TRUE;
//rest of script...
//include my changes
for ($j=1;$j<$newMail;$j++)
{
$row[$j] = mysql_fetch_array($result[$j]);
If ($row[\"email_address\".$j.\"\"] == $email_address[$j])
{
$ErrorString .= \"Email Address #\".$j.\" already exists. Please choose another.<BR>\n\";
$errormsg .= $ErrorString;
}
}
return $errormsg;
}
Hope that helps...
---John Holmes...