Here is my code, which uses an extended phpMailer. This works if I check for firstResult and lastResult, but not if I check for emailResult:
$validator = new FormValidator();
$firstResult = $validator->checkFirst($_POST['firstname']);
$lastResult = $validator->checkLast($_POST['lastname']);
$emailResult = $validator->checkEmail($_POST['emailaddress1']);
var_dump($emailResult);
if (is_null($firstResult) && is_null($lastResult) && is_null($emailResult)) {
$mail = new ULSMail();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->AddAddress("[email protected]");
$mail->Subject = "test";
$mail->MsgHTML($messageHTML);
redirectULS('english/forms/thankyou.php');
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
//$bridge->pushLead($lead);
}
} else {
//...
}
and in my FormValidator class:
function checkEmail($email){
if(strlen(trim($email)) < 8){
return 'Please enter a valid email address of more than 8 characters</span>';
} else {
return NULL;
}
}
redirectULS is a simple redirect function for internal redirects on my site. It works as long as I don't check for $emailResult.