Email Validation (Block Unwanted Addresses)

Email Validation (Block Unwanted Addresses)

am 24.01.2008 12:20:50 von ibizara

@$email = addslashes($_POST['email']);

if (! ereg('^[*a-z\'0-9]+([._-][*a-z\'0-9]+)*@([a-z0-9]+([._-][a-
z0-9]+))+$', $email))
{
include_once("error.inc");
die();
}

---
I need to add a if contains the below then include_once("error.inc");

Spam = /.*@(hsbc|barclays|hotmail)\.com$/.test(Addr)

---
Many Thanks to any replys in advanced!

Regards,
Jason

Re: Email Validation (Block Unwanted Addresses)

am 24.01.2008 12:45:45 von luiheidsgoeroe

On Thu, 24 Jan 2008 12:20:50 +0100, ibizara wro=
te:

> @$email =3D addslashes($_POST['email']);
>
> if (! ereg('^[*a-z\'0-9]+([._-][*a-z\'0-9]+)*@([a-z0-9]+([._-][a-
> z0-9]+))+$', $email))

You do realise this will make a lot of valid emailadresses invalid? =

Domains are not limited to the ascii set for instance, and [a-z0-9'._-] =
=

are not the only valid characters in an email name.
Also, it's recommended to use the preg_* functions instead of ereg*

> {
> include_once("error.inc");
> die();
> }
>
> ---
> I need to add a if contains the below then include_once("error.inc");
>
> Spam =3D /.*@(hsbc|barclays|hotmail)\.com$/.test(Addr)

Hmmm? I often use my spambucket hotmail address (see my mailaddress :) )=
of =

10 years ago for sites I'm not sure about. (Yes, I can still access it, =
=

but I normally won't unless I just registered with that mail / about onc=
e =

every 1 or 2 months)

if(preg_match('/@(hsbc|barclays|hotmail)\.com$/i',$email)){
//the code
}
-- =

Rik Wasmus

Re: Email Validation (Block Unwanted Addresses)

am 24.01.2008 13:38:18 von ibizara

> Hmmm? I often use my spambucket hotmail address (see my mailaddress :) )of=
=A0
> 10 years ago for sites I'm not sure about. (Yes, I can still access it, =
=A0
> but I normally won't unless I just registered with that mail / about once =
=A0
> every 1 or 2 months)
>
> if(preg_match('/@(hsbc|barclays|hotmail)\.com$/i',$email)){
> //the code}

// Receiving variables
@$email =3D addslashes($_POST['email']);

if (! ereg('^[*a-z\'0-9]+([._-][*a-z\'0-9]+)*@([a-z0-9]+([._-][a-
z0-9]+))+$', $email)){
include_once("error.inc");
die();
}

if(preg_match('/@(hotmail|rbs|barclays|lloydstsb|hsbc|natwes t)\.(com|co
\.uk)$/i',$email)){
include_once("not_allowed.inc");
die();
}

==================== ==
Thanks for the help :)
==================== ==

For info this is just for a whitelist that we have created for users
to add email addresses into.
Although I do not wish for *@hotmail.com to come through I do wish for
user@hotmail.com to come through.

Any guidance on using the " * " not as a wildcard... ??
if(preg_match('[*]/@(hotmail... ??

Thanks,
J

Re: Email Validation (Block Unwanted Addresses)

am 24.01.2008 14:55:32 von ibizara

> Any guidance on using the " * " not as a wildcard... ??
> if(preg_match('[*]/@(hotmail... ??

if(preg_match('/\*@(hotmail|rbs|barclays|lloydstsb|hsbc|natw est)\.(com|
co\.uk)$/i',$email)){

Found I only needed to add \*

So all sorted and working a treat :)