On an Email form I am learning to program I don't want the script to run the a function if the the CC or BCC fields are empty. I tried both isset($GET) and empty($GET) and it still runs through the function. When it does not find an "@" or a "." it returns false, does the echo and halts.
The problem must be in the else if statement, because if the 'cc' field on the html form is null it should never go to the function.
I have only posted part of my code below. If you need to see the complete HTML code and all of the PHP file I can post them. The function also validates other addresses.
function validateRecipients($Addresses) {
$Address = explode(",", $Addresses);
$RetValue = true;
foreach ($Address as $Email) {
if (strpos($Email, '@') !== FALSE && strpos($Email, '.') !== FALSE)
$RetValue = true;
else {
$RetValue = false;
break;
}
}
return $RetValue;
}
//////////////////////////////////
else if (isset($_GET['cc']) && validateRecipients($CC) == false)
echo "something";