student101
05-09-2008, 12:07 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;
}
?>
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;
}
?>