bubblybabs Posted April 24, 2007 Share Posted April 24, 2007 I wish to exclude a specific email address when one sends an ecard from my site. How does one exlude this email address but allow all others to continue on their merry way? Code currently used: function validEmail($address) { if (eregi("^[a-z0-9]([\._\-]?[a-z0-9])*@[a-z0-9]([\.\-]?[a-z0-9])*\.[a-z]{2,}$", $address)) return true; else return false; } Thank-you, Babs Link to comment https://forums.phpfreaks.com/topic/48482-solved-how-to-exclude-a-specific-email-address/ Share on other sites More sharing options...
taith Posted April 24, 2007 Share Posted April 24, 2007 if(validEmail($_POST[email])){ if(strpos($_POST[email],'[email protected]')!==false){ FLEEFROMMYWRATH($baduser); }else{ } } Link to comment https://forums.phpfreaks.com/topic/48482-solved-how-to-exclude-a-specific-email-address/#findComment-237076 Share on other sites More sharing options...
bubblybabs Posted April 24, 2007 Author Share Posted April 24, 2007 taith, I so appreciate your quick response... Please give me a clue as to how to add this snippet of coding into what I already have... Should it be as such? function validEmail($address) { if (eregi("^[a-z0-9]([\._\-]?[a-z0-9])*@[a-z0-9]([\.\-]?[a-z0-9])*\.[a-z]{2,}$", $address)) return true; else return false; } if(validEmail($_POST[email])){ if(strpos($_POST[email],'[email protected]')!==false){ FLEEFROMMYWRATH($baduser); }else{ } } Babs Link to comment https://forums.phpfreaks.com/topic/48482-solved-how-to-exclude-a-specific-email-address/#findComment-237115 Share on other sites More sharing options...
taith Posted April 24, 2007 Share Posted April 24, 2007 sorry... not really sure what you mean by that... this should work as is... but it really depends on how your script works... function validEmail($address){ if(eregi("^[a-z0-9]([\._\-]?[a-z0-9])*@[a-z0-9]([\.\-]?[a-z0-9])*\.[a-z]{2,}$", $address)) return true; else return false; } if(validEmail($_POST[email])){ if(strpos($_POST[email],'[email protected]')!==false){ die('I dont like that user... go away!'); }else{ #continue your script } } Link to comment https://forums.phpfreaks.com/topic/48482-solved-how-to-exclude-a-specific-email-address/#findComment-237118 Share on other sites More sharing options...
bubblybabs Posted April 24, 2007 Author Share Posted April 24, 2007 My dear, this is looking good... I had to modify this a bit to work in the script I am using but it worked... One exception, how does one make it so that it's not case sensitive? Right now, if I were to put this email address into the code: [email protected] but the person typed in : [email protected] it will go through. An error is produced if the two are typed in exactly the same however... Also, is there a way to block all emails from a specific domain? For example, all emails to @happy.com? Thanks, Babs Link to comment https://forums.phpfreaks.com/topic/48482-solved-how-to-exclude-a-specific-email-address/#findComment-237163 Share on other sites More sharing options...
bubblybabs Posted April 24, 2007 Author Share Posted April 24, 2007 I think I found the answer... I changed strpos to stristr... Is this correctly used? function validEmail($address) { if(eregi("^[a-z0-9]([\._\-]?[a-z0-9])*@[a-z0-9]([\.\-]?[a-z0-9])*\.[a-z]{2,}$", $address)) return true; else return false; } if(validEmail($_POST[to_email])){ if(stristr($_POST[to_email],'[email protected]')!==false){ die('I am sorry but you are not allowed to send to that email address. Please go <a href="compose.php">back</a> and fix the error.'); }else{ return false; } } I can put in [email protected] and change any letter to a capital and it seems to give me the error message so I think this is correct... Thanks, Babs Link to comment https://forums.phpfreaks.com/topic/48482-solved-how-to-exclude-a-specific-email-address/#findComment-237188 Share on other sites More sharing options...
taith Posted April 24, 2007 Share Posted April 24, 2007 yes... it would work that way... :-) strpos() is faster... just if you go that way, just strtolower() the $_POST'd email first... Link to comment https://forums.phpfreaks.com/topic/48482-solved-how-to-exclude-a-specific-email-address/#findComment-237206 Share on other sites More sharing options...
bubblybabs Posted April 24, 2007 Author Share Posted April 24, 2007 OK, took me a bit to figure this out: function validEmail($address) { if(eregi("^[a-z0-9]([\._\-]?[a-z0-9])*@[a-z0-9]([\.\-]?[a-z0-9])*\.[a-z]{2,}$", $address)) return true; else return false; } if(validEmail($_POST[to_email])) { if(strpos(strtolower($_POST[to_email]),'[email protected]')!==false) { die('So sorry but you are not allowed to send to that email address. Please go <a href="compose.php">back</a> and resend to another email address. Thank-you!.'); }else{ return false; } } Is that correctly coded? Thanks bunches... Babs Link to comment https://forums.phpfreaks.com/topic/48482-solved-how-to-exclude-a-specific-email-address/#findComment-237285 Share on other sites More sharing options...
taith Posted April 24, 2007 Share Posted April 24, 2007 does it work? Link to comment https://forums.phpfreaks.com/topic/48482-solved-how-to-exclude-a-specific-email-address/#findComment-237460 Share on other sites More sharing options...
bubblybabs Posted April 25, 2007 Author Share Posted April 25, 2007 *giggles* Yes, it works! I just worry I've gotten it to work but some hidden other "side-code" is occurring w/o my knowledge! :-) Many thanks taith, I appreciate your assistance and helping me learn yet another fascinating snippet of php... Consider this solved! Babs Link to comment https://forums.phpfreaks.com/topic/48482-solved-how-to-exclude-a-specific-email-address/#findComment-237724 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.