zc1 Posted October 5, 2007 Share Posted October 5, 2007 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 [email protected] would the below code echo the message or would it let it pass and only block [email protected] ? Also does anyone know if it is case sensitive ? Finally how would I have to to check for .EXT and .EXT1 etc..., would I need to repeat the code or can I have it all within the same code, if so how ? // test block of *.EXT emails if ( preg_match( "#\.EXT$#", $email ) ) { echo 'The email address you entered is not allowed.'; exit; } Regards, Garry Link to comment https://forums.phpfreaks.com/topic/71969-solved-preg_match-to-block-email-addresses/ Share on other sites More sharing options...
MadTechie Posted October 5, 2007 Share Posted October 5, 2007 hope this helps // test block of *.EXT emails if ( preg_match( "#(?:\.EXT||\.co\.uk||\.EXT1||\.EXT2)$#i", $email ) ) { //NOTE the i after the # (for case insensitive) echo 'The email address you entered is not allowed.'; exit; } Link to comment https://forums.phpfreaks.com/topic/71969-solved-preg_match-to-block-email-addresses/#findComment-362493 Share on other sites More sharing options...
zc1 Posted October 5, 2007 Author Share Posted October 5, 2007 Hi, So will it now only check the end of the domain with MadTechie code ? For example [email protected] will this be passed and [email protected] will get the message Regards, Garry Link to comment https://forums.phpfreaks.com/topic/71969-solved-preg_match-to-block-email-addresses/#findComment-362500 Share on other sites More sharing options...
MadTechie Posted October 5, 2007 Share Posted October 5, 2007 the Following are example of what will fail tedsfsdst.ext tfdsfest.eXt tefdsfsdst.co.Uk tefdsfsdst.eXt1 tcsdadfdsfsdest.ext2 EDIT: remove ||\.co\.uk to allow the .co.uk Link to comment https://forums.phpfreaks.com/topic/71969-solved-preg_match-to-block-email-addresses/#findComment-362502 Share on other sites More sharing options...
zc1 Posted October 5, 2007 Author Share Posted October 5, 2007 Hi, Thanks Regards, Garry Link to comment https://forums.phpfreaks.com/topic/71969-solved-preg_match-to-block-email-addresses/#findComment-362504 Share on other sites More sharing options...
MadTechie Posted October 5, 2007 Share Posted October 5, 2007 can you click solved (Bottom left) if it is solved cheers Link to comment https://forums.phpfreaks.com/topic/71969-solved-preg_match-to-block-email-addresses/#findComment-362507 Share on other sites More sharing options...
zc1 Posted October 5, 2007 Author Share Posted October 5, 2007 Hi, I had just tested this and I don't think it working right as the message is displaying all the time, even when .ext or .ext1 not in the email address. I have made a test script to test it, see below for code <?php $email = '[email protected]'; echo $email; echo '<br><br>'; // test block or *.EXT and *.EXT1 emails //if ( preg_match( "#\.EXT$#i", $email ) ) { if ( preg_match( "#(?:\.EXT||\.EXT1)$#i", $email ) ) { echo 'The email address you entered is not allowed.'; exit; } ?> Any idea why ? Link to comment https://forums.phpfreaks.com/topic/71969-solved-preg_match-to-block-email-addresses/#findComment-362523 Share on other sites More sharing options...
MadTechie Posted October 5, 2007 Share Posted October 5, 2007 LOL, my bad || should be | this should work <?php $email = '[email protected]'; echo $email; echo '<br><br>'; // test block or *.EXT and *.EXT1 emails //if ( preg_match( "#\.EXT$#i", $email ) ) { if ( preg_match( "#(?:\.EXT|\.EXT1)$#i", $email ) ) { echo 'The email address you entered is not allowed.'; exit; } ?> || = OR in PHP | = OR in RegEx Link to comment https://forums.phpfreaks.com/topic/71969-solved-preg_match-to-block-email-addresses/#findComment-362546 Share on other sites More sharing options...
zc1 Posted October 5, 2007 Author Share Posted October 5, 2007 Hi, Thanks again I just worked it out myself too was going to post and ask about the double | if it should be single. But as you replyed I will not both Thanks again Link to comment https://forums.phpfreaks.com/topic/71969-solved-preg_match-to-block-email-addresses/#findComment-362550 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.