You already have the email in $email, so just use that:


if(strpos($errorMessage, $email) !== false) {
$regMessage = $email . " has already been registered";
}
else {
// some other error?...