proggybilly
Programmer
I have a form in an app that I inherited for creating email addresses. The form passes the user part , the domain part separately to a function that puts them together to make an email address and then validates everything up to the @. Problem is some admins have been putting the whole email address in the user part of the form so I need to look at that part and if there is an @, then return a message stating that there are invalid characters. I have this expression, but it seems to not work.
Any ideas on what I am doing wrong? I believe that this says if $user is not a-z, A-Z, 0-9, an _, a -, or a . that it should return $return.
Code:
trim($user);
if (! preg_match("/[a-zA-Z0-9_\-\.]/",$user))
{
return "User $user contains invalid characters<br>";
}
Any ideas on what I am doing wrong? I believe that this says if $user is not a-z, A-Z, 0-9, an _, a -, or a . that it should return $return.