PDA

View Full Version : Deny certain email domains?


student101
05-09-2008, 12:06 PM
How would I be able to deny users with certain email domains from registering.

Example:
A User has yahoo, gmail or webmail accounts.
They want to register with one of these emails on the site but the site does not allow "email@ yahoo.com", "email@ gmail.com" and so on.

What am I looking at doing to get this done? Pure PHP, .htaccess or something else

Here is some dummy code to help understand what I mean.
<?php
$domain = substr(strrchr($email, "@"), 1);
$baned_domains = array('yahoo.net', 'yahoo.com', 'gmail.com', 'google.com', 'and so on...');
if (in_array($domain, $baned_domains)){
$msg = 'Your email address is not allowed. Please re-submit with an alternate address.';
}
?>
<?php
function custom_emailblacklist($email)
{
$blocking = Array( 'yahoo.net', 'yahoo.com', 'gmail.com', 'google.com', 'and so on...');
foreach ($blocking as $addr) {
if (strpos($email, $addr) !== FALSE) {
accessLog("tried to register $email");
return TRUE;
}
}
return FALSE;
}
?>

student101
05-09-2008, 02:15 PM
Fixed with the old fashioned way PHP, YAY!!!

$emailadd = explode("@", $email);
echo $emailadd[1];


Not much of an Array man

domedia
05-09-2008, 02:51 PM
Nice!

What kind of system would do this? I wold seriously pissed if I tried to register somewhere only to get the message "Your email address is not allowed."...

davidj
05-09-2008, 07:33 PM
thats a neat little explode

here is another take on the same thing


list($shite, $domain) = explode('@', $email); //<< list breaks your array into single vars


Are you excluding people here. I dont use a POP3 any more because of the spam it attracted so i cant be in your gang.

student101
05-10-2008, 08:27 AM
Nice!
What kind of system would do this? I wold seriously pissed if I tried to register somewhere only to get the message "Your email address is not allowed."...
I am only using it for gmail, yahoo and porn sites.

The reason:
When I have questions or run surveys I only get one or two users responding due to the fact: how often do you check your gmail or yahoo account?
I prefer to have a proper working email.

I develop community websites or blogs where users have their own control panel.
I just finished with my conversion from TABLES to CSS, WOW you wont believe how fast it is with CSS, I can't even believe it.

Cheers

student101
05-10-2008, 08:31 AM
thats a neat little explode
here is another take on the same thing

list($shite, $domain) = explode('@', $email); //<< list breaks your array into single vars

Are you excluding people here. I dont use a POP3 any more because of the spam it attracted so i cant be in your gang.
What do you use? if not POP3

I was looking at my code and was wondering if I could make it less.
I am using the famous switch that you showed me more about, but each case has to query the database.
I guess it can't be shortened.

Cheers

davidj
05-10-2008, 10:13 AM
What do you use? if not POP3



Live Mail (once hot mail)

i think the junk filters are second to none and i don't have to download stuff i don't have to. After years of seeing 100's of emails in my junk folder i got sick of them. Yes they are neatly and correctly categorised in a junk folder but at the end of the day i have download them! This to me screams of pointlessness so i moved across to Live Mail and have been using this for many years now. So please remember that there are people like me who use their web based mail account daily.


I am using the famous switch that you showed me more about, but each case has to query the database.
I guess it can't be shortened.



post the code and we will see if we can help

student101
05-10-2008, 10:44 AM
Could I PM it to you?

Cheers

davidj
05-10-2008, 03:59 PM
i dont do one to one help sorry

the aim is to enlighten people while helping you out

student101
05-10-2008, 04:28 PM
This and other forums are one to one.
User asks a question - another user answers it, users see what the one user helped the other one out with, ie: one to one
This will be available to "enlighten people" once it's complete.
The tutorial is only half way complete the database and so on still needs work.

Dreamweaver and other applications can't or don't do what I have developed (by hand), once I figure out how these extensions work I could make one of them instead, for now it's all by hand.

This is a very simple, cool idea that has bugged many developers.
How to validate! What to validate and so on.

This Ajax, javascript that I have been busy with:

Checks Usernames On the FLY! (if registered)
Checks Email Addresses On the FLY! (if registered)
Checks Email domains On the FLY! (if allowed)
Need to add more, not really sure yet.Cheers

domedia
05-10-2008, 04:37 PM
This and other forums are one to one.
What DJ is saying is that this is a DW forum, not a one-to-one tutoring service through private messaging. ;)

davidj
05-10-2008, 04:38 PM
This and other forums are one to one.

your definition of one to one is different. You requested this help via email

I help people in the FORUM so others can see and take that lesson away with them.

are you hand coding this?

student101
05-10-2008, 04:41 PM
What DJ is saying is that this is a DW forum, not a one-to-one tutoring service through private messaging. ;)
What's the point of private messaging? :)

davidj
05-10-2008, 04:41 PM
What DJ is saying is that this is a DW forum, not a one-to-one tutoring service through private messaging. ;)

not for free anyhoo

student101
05-10-2008, 04:42 PM
your definition of one to one is different. You requested this help via email
I help people in the FORUM so others can see and take that lesson away with them. are you hand coding this?
yes, by standard PHP, Ajax and javascript way, yes

davidj
05-10-2008, 04:42 PM
What's the point of private messaging? :)

for me to tell people how to boil their head when they ask for help via it

davidj
05-10-2008, 04:44 PM
yes, by standard PHP, Ajax and javascript way, yes

so what are you having trouble with

student101
05-10-2008, 04:44 PM
I am a bit lost here, you offered to help, I don't recall asking you for it.

student101
05-10-2008, 04:48 PM
so what are you having trouble with
Once the TUT is finished, you can comment on it and let me know what you think would work out better, that way it wont be one to one.

Cheers

davidj
05-10-2008, 04:50 PM
I am a bit lost here

OK

here is a map in pseudo format...

IF(your having problems and require guidance){

echo "POST YA CODE";

}

student101
05-10-2008, 04:53 PM
That's a good one, just helped me realize that I only have one if in my code.
Thanks

davidj
05-10-2008, 05:10 PM
excellent

that could have been resolved in post 1