current: preg_match('/^[\w\.\-]+@[\w\.\-]+\.\w\w\w?$/', $email)
a friend typoed nrt for net. so i figure even with two feilds ineed a better check. i want to allow the two letter country codes and all the 3/4 letter domains (i don't see anyone using museum)
does anyone know a place that has an up to date list? will the others with prel reg exp skim this quickly and make sure i didn't screw up (i find that i have a tendency to make minor mistakes, if i did it should be caught by one of you i expect... don't have a way to test this until i can get a friend to try it, which might be after you look at it)
new: preg_match('/^[\w\.\-]+@[\w\.\-]+\.(\w\w|biz|com|org|gov|net|info)$/', $email)
help making a better email check
Moderator: General Moderators
There are LOADS (and I mean LOADS) of domain extensions in the world (one for each country + others).
Off the top of my head you could add .co.uk - .uk.com - .jp - .de - and so on.
Check out http://www.alldomains.com/alltlds.html for a full list but prepare yourself for a shock.
And also don't presume that someone won't use a certain domain name... if it exists then someone somewhere will be using it
Off the top of my head you could add .co.uk - .uk.com - .jp - .de - and so on.
Check out http://www.alldomains.com/alltlds.html for a full list but prepare yourself for a shock.
And also don't presume that someone won't use a certain domain name... if it exists then someone somewhere will be using it
mwong: that's what this is for, but certain ones are more obvious than others. this is before checking that it's fake... making sure that the address MIGHT be valid. the way i had it a friend mistyped net nrt and it went through the email catch. the only other thing i can think of to do is to have the join send an email for confirmatiln and then when you confirm that it goes into asking for what i need to go farther... might just do that...
genik: this is just to check the top level is valid.i forgot mil and the ontly one not listed here i had was edu. looks like there's more to add... and i think i'll split joining to two scripts. one to agree to the terms and get the mail sent, one to actually join once that's been verified... still wont hurt to check on the top levels
genik: this is just to check the top level is valid.i forgot mil and the ontly one not listed here i had was edu. looks like there's more to add... and i think i'll split joining to two scripts. one to agree to the terms and get the mail sent, one to actually join once that's been verified... still wont hurt to check on the top levels
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
I always tend to use this:
Then send them an email just to make sure they recieve it and prove that they own the given email address. Guess you could also do a few checks on the domain name before you send the mail to ensure that its valid and in use.
Code: Select all
<?php
ereg("^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", $email);
?>