Jump to content

[SOLVED] How to exclude a specific email address


bubblybabs

Recommended Posts

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

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

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
}
}

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

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

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

*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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.