note 18542 added to function.eregi
| From: | mmc at nospam dot dk | Date: | Sun, 27 Jan 2002 11:56:51 +0000 |
| Subject: | note 18542 added to function.eregi | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-25865@lists.php.net to get a copy of this message | ||
I'm not sure about "\." being the same as "." above.
Anyway, the mentioned regex would not recognize .museum-names, and generally isn't future safe.
Also, it doesn't verify that usernames and hostnames cannot start with "-._".
I would recommend a more general (=future safe) expression and then instead check the hostname. An
example:
if( !eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*"
."@([a-z0-9]+([\.-][a-z0-9]+))*$",
$mail, $regs) )
{
echo "Error: '$mail' isn't a valid mail address!\n";
}
elseif( gethostbyname($regs[2]) == $regs[2] )
{
echo "Error: Can't find the host '$regs[2]'!<br>\n";
}
Note: I had to split the regex for it to fit this note.
Also note: The reason I'm using gethostbyname() and not getmxrr() or such is that getmxrr()
doesn't work on Win2000/XP.
--
http://www.php.net/manual/en/function.eregi.php
http://master.php.net/manage/user-notes.php?action=edit+18542
http://master.php.net/manage/user-notes.php?action=delete+18542
http://master.php.net/manage/user-notes.php?action=reject+18542