NSW42 Posted February 24, 2008 Share Posted February 24, 2008 Heya all, just need some help or ideas on registration with emails, what id like to have is block certain email addresses or domains when users join up, so if its a certain email address it says when they click signup that email address is not allowed or valid any help would be appreciated, some coding below to help out. Many Thanks if((!isset($email_address)) || (!isset($username)) || (!isset($nickname)) || (!isset($password)) || (!isset($password2)) || ($password!=$password2) || (!ereg("^[A-za-z0-9]+$",$_POST['username'])) || (!ereg("^.+\..+$",$_POST['email_address'])) || ($checku > 0) || ($checkn > 0)|| ($checke > 0)) { print("Please fix the following.<BR>"); if(!isset($_POST['email_address'])) { print("Enter a email address.<BR>"); } if(!isset($_POST['username'])) { print("Enter a username.<BR>"); } if(!isset($_POST['nickname'])) } if(!isset($_POST['password'])) { print("Enter a password.<BR>"); } if(!isset($_POST['password2'])) { print("Enter a confirm password.<BR>"); } if($_POST['password']!=$_POST['password2']) { print("Password and confirm do not match!.<BR>"); unset($password); unset($password2); } if(!ereg("^[A-za-z0-9]+$",$_POST['username'])) { print("Enter a Valid username with letters and numbers only.<BR>"); unset($username); } if(!ereg("^.+\..+$",$_POST['email_address'])) { print("Enter a valid email address.<BR>"); unset($email_address); } if($checku > 0) { print("Username already in use!<BR>"); unset($username); } if($checkn > 0) { print("Nickname already in use!<BR>"); unset($nickname); } if($checke > 0) { print("Email already in use!"); unset($email_address); } Quote Link to comment https://forums.phpfreaks.com/topic/92657-solved-block-email-addresses-or-domains-on-signup/ Share on other sites More sharing options...
NSW42 Posted October 19, 2008 Author Share Posted October 19, 2008 hmm after so long, im just wondering if anyone here can shed some light on this post as I wouldnt mind finishing what I started Regards Quote Link to comment https://forums.phpfreaks.com/topic/92657-solved-block-email-addresses-or-domains-on-signup/#findComment-668895 Share on other sites More sharing options...
corbin Posted October 19, 2008 Share Posted October 19, 2008 $BlockedNames = array('blah', 'bleh', 'something'); $BlockedDomains = array('something.com', 'something.something'); $email = "test@domain.com"; list($name, $domain) = explode("@", $email); if(in_array($name, $BlockedName) || in_array($domain, $BlockedDomain)) { //blocked } Quote Link to comment https://forums.phpfreaks.com/topic/92657-solved-block-email-addresses-or-domains-on-signup/#findComment-668961 Share on other sites More sharing options...
NSW42 Posted October 19, 2008 Author Share Posted October 19, 2008 $BlockedNames = array('blah', 'bleh', 'something'); $BlockedDomains = array('something.com', 'something.something'); $email = "test@domain.com"; list($name, $domain) = explode("@", $email); if(in_array($name, $BlockedName) || in_array($domain, $BlockedDomain)) { //blocked } lol heya corbin and thanks for the reply, could you explain how that works and where I would exactly place that in the script Regards Quote Link to comment https://forums.phpfreaks.com/topic/92657-solved-block-email-addresses-or-domains-on-signup/#findComment-668985 Share on other sites More sharing options...
corbin Posted October 19, 2008 Share Posted October 19, 2008 No offense man, but that's very, very simple. If you don't know how that works, just look up each function in the PHP manual and look at how it's being used. The code block would be used in the validation process. Quote Link to comment https://forums.phpfreaks.com/topic/92657-solved-block-email-addresses-or-domains-on-signup/#findComment-668993 Share on other sites More sharing options...
NSW42 Posted October 19, 2008 Author Share Posted October 19, 2008 ah na no offence taken, I can see how it works, but just cant see where to place it in the script is all, I started all this from scratch and im still learning as I go along. Quote Link to comment https://forums.phpfreaks.com/topic/92657-solved-block-email-addresses-or-domains-on-signup/#findComment-669007 Share on other sites More sharing options...
NSW42 Posted October 19, 2008 Author Share Posted October 19, 2008 ok ive tried it right thru out the script with a test for blocking hotmail and it doesnt seem to block anything, just inserts to valids as usual, maybe im placing it wrong but did try a few diff ways, any suggestions. Regards Quote Link to comment https://forums.phpfreaks.com/topic/92657-solved-block-email-addresses-or-domains-on-signup/#findComment-669039 Share on other sites More sharing options...
corbin Posted October 19, 2008 Share Posted October 19, 2008 if(in_array($name, $BlockedName) || in_array($domain, $BlockedDomain)) { Should've been if(in_array($name, $BlockedNames) || in_array($domain, $BlockedDomains)) { My bad x.x. Quote Link to comment https://forums.phpfreaks.com/topic/92657-solved-block-email-addresses-or-domains-on-signup/#findComment-669073 Share on other sites More sharing options...
NSW42 Posted October 19, 2008 Author Share Posted October 19, 2008 sorry but still no go ??? Quote Link to comment https://forums.phpfreaks.com/topic/92657-solved-block-email-addresses-or-domains-on-signup/#findComment-669078 Share on other sites More sharing options...
corbin Posted October 19, 2008 Share Posted October 19, 2008 if($_POST) { $email = (isset($_POST['email'])) ? $_POST['email'] : ''; $BlockedNames = array('blah', 'bleh', 'something'); $BlockedDomains = array('something.com', 'something.something'); @list($name, $domain) = explode("@", $email); if(in_array($name, $BlockedNames) || in_array($domain, $BlockedDomains)) { echo 'Blocked'; } } echo <<<H <form action="" method="POST"> <input type="text" name="email" /><br /> <input type="submit" value="Go" /> </form> H; Quote Link to comment https://forums.phpfreaks.com/topic/92657-solved-block-email-addresses-or-domains-on-signup/#findComment-669361 Share on other sites More sharing options...
NSW42 Posted October 20, 2008 Author Share Posted October 20, 2008 many thanks to corbin for his help, worked out like a charm Quote Link to comment https://forums.phpfreaks.com/topic/92657-solved-block-email-addresses-or-domains-on-signup/#findComment-669656 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.