Client Support Community Server Status Contact Us Client Login
Email Hosting Website Hosting Reseller Hosting VPS Hosting Dedicated Servers

    Join our Community      Check your private messages       Profile       Search       FAQ       Memberlist       Log in


preg_match to block email address(es)

 
Post new topic   Reply to topic    NetHosted Community Index -> Web Design
Garry Reply with quote
 NetHosted Customer

 

 Joined: 03 Oct 2005
 Posts: 246
 Location: Lincoln, UK

PostPosted: Fri Oct 05, 2007 2:45 pm    Post subject: preg_match to block email address(es)
 
Hi,

I have found the below code I change it to *.EXT instead of the ending of the email address for example *.com

Now if someone had abc.EXT@my-domain.co.uk would the below code give the message or would it let it pass ?

Also is it case sensitive ?

// test block of *.EXT emails
if ( preg_match( "#\.EXT$#", $email ) ) {
echo 'The email address you entered is not allowed.';
exit;
}

_________________
Regards,
Garry
Happy NetHosted Customer
Back to top
View user's profile Send private message
Garry Reply with quote
 NetHosted Customer

 

 Joined: 03 Oct 2005
 Posts: 246
 Location: Lincoln, UK

PostPosted: Fri Oct 05, 2007 3:36 pm    Post subject:
 
Hi,

I think I have sorted this now, got some help, will try and post the code, once I have finished testing

_________________
Regards,
Garry
Happy NetHosted Customer
Back to top
View user's profile Send private message
Garry Reply with quote
 NetHosted Customer

 

 Joined: 03 Oct 2005
 Posts: 246
 Location: Lincoln, UK

PostPosted: Fri Oct 05, 2007 4:21 pm    Post subject:
 
Hi,

Below is the test code script. Thanks to PHP Freaks forum for the help

If email was
xyz.test @ mydomain.ext - It would echo the message
xyz.test @ mydomain.ext1 - It would echo the message
xyz.ext @ mydomain.com - It would not exho message
xyz.ext1 @ mydomain.com - It would not exho message
Without the space between the @

It also work if it was .eXt and .ExT1

Code:

<?php

$email = 'xyz.test@mydomain.ext';

echo $email;
echo '<br><br>';

// test block of *.ext and *.ext1 emails
if ( preg_match( "#(?:\.ext|\.ext1)$#i", $email ) ) {
echo 'The email address you entered is not allowed.';
exit;
}

?>

_________________
Regards,
Garry
Happy NetHosted Customer
Back to top
View user's profile Send private message
Post new topic   Reply to topic    NetHosted Community Index -> Web Design
Page 1 of 1

User Permissions
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum

 
Jump to: