| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Regular Join Date: Apr 2006 Location: lolz
Posts: 715
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Modifying website registration. First off, I'm a complete n00b with this kind of stuff, so bare with me ![]() Okay. Say I have a website script. I want to modify it so people can ONLY register if they have 1 specific e-mail domain. for example: it will only allow members with yahoo.com e-mails to register. if you have gmail, it won't work. is this possible using php? (well, i'd imagine it would be php) thanks so much in advance
__________________ ●available for design work ●pm if interested |
| |
| | #2 (permalink) |
| NamePros Regular Join Date: May 2004 Location: NYC
Posts: 236
![]() ![]() ![]() | Here you go: PHP Code: The validator is case insensitive, so YAHOO and yahoo and YaHOo .cOm or .COM (etc.) are all valid. Tested and works |
| |
| | #4 (permalink) |
| NamePros Regular Join Date: May 2004 Location: NYC
Posts: 236
![]() ![]() ![]() | My pleasure, I had a validator sitting around. Enhancing it was fun. Here's one that has a couple of more features yet (I've been playing ). Examples in the function header, description below.NOTE: bbcode is inserting some odd spaces in the comment header and examples. The actual function code is fine. 1. The $domain parameter can be an array or a string, so you can provide multiple domains to test for, not just one. Pass a string, only one is tested. Pass an array, the whole list is tested. 2. There is a third parameter, indicating whether the list is an ALLOW list, or a DISALLOW list. If the parameter is TRUE, then the email address MUST be from $domain. If the parameter is FALSE, then the email address MUST NOT be from the domains in the list. It sounds more complicated than it is. The one-line examples are self-explanatory. Tested and works. PHP Code: |
| |
| | #6 (permalink) |
| NamePros Regular Join Date: May 2004 Location: NYC
Posts: 236
![]() ![]() ![]() | Thanks ![]() New code below to correct a minor bug: emails ending with things like .co.uk or .co.in failed to validate. That's fixed, as well as a little further streamlining of the code to do only one preg match. NOTE that the last parameter now defaults to TRUE instead of FALSE. PHP Code: |
| |