PHP: email validation form
- Started
- Last post
- 12 Responses
- fifty50
I've got this PHP email validation form on my site:
http://curtis.nexteradesign.com/…
That's basically the meat of it. For some reason, though, some valid email addresses get returned as being invalid. For example or come back as being invalid, even though the domains are in fact valid. Help?
- UndoUndo0
you got mail!
- ldww0
i see you are using getmxrr. why not try the example in the comments? they do it a bit differently then you.
- fifty500
thanks guys i'll give them both a shot and see what happens.
- kinetic0
this function has always served me well:
function check_email($email) {
if(eregi("^[a-z0-9\._-]+@+[a-z0... $email)) {
return TRUE;
} else {
return FALSE;
}
}
- ldww0
kinetic, that is just a regex. he wants to check the hostname to see if it is a valid host rather then whatevernameusertypes.com. reg ex will just see if it looks right, not valid.
- fifty500
Ed Zachary what ldww said
- UndoUndo0
curtis what I sent to you will check that the email address 'looks right' not that it has valid mail exchange records, you might want to add that from yr other function
- fifty500
oh feck. that was the original problem. what I had was validating most emails but my buddy tried it with his and it came back as invalid!
- kinetic0
sorry mate...should have read your post
im always doing that ;)
- ldww0
as a sidenote, i have never actually checked the hostname. i think most people are content with making sure the email looks right.
if you are very concerned about a vlid email address just require email confirmation by sending them an email with some kind of keycode.
- UndoUndo0
this will validate emails in the correct format
ie. use@domani.extension
will validate
but
john&john@somedomain.$uperwont
but will not check that the domain has a valid mail exchange record. sorry for the confusion
- UndoUndo0
I agree with ldww, checking mail exchange records isnt that robust just make sure they validate the email with an activation code,
I could submit yr email address and it will validate with MX record but its not mine, so activation through email is more reliable IMO