note 68593 added to function.eregi

From: Date: Wed, 02 Aug 2006 21:29:56 +0000
Subject: note 68593 added to function.eregi
Groups: php.notes 
Request: Send a blank email to php-notes+get-115503@lists.php.net to get a copy of this message
One more comment about email validation and usability of validators. The fact that RFC 2822 allows broader set of characters in email addresses than typically used makes things quite challenging usability wise. A very common usability problem with email validators is that they do not accept all valid addresses (such as foo{bar}.baz!@example.com. Almost as common problem is that the validator only checks that the syntax is valid and passes addresses like foo#@example.com without any warning. Even though foo#@example.com is syntactically valid it might just as well be a typo of foo@example.com. I resolved this usability challenge by doing the validation in two phases. In the first phase the address is validated so that it can't include exotic characters like { or |. Most addresses pass this validation. If they don't, they are validated with the other validator that allows all RFC-compliant addresses. In this case the validator shows a message that the address is syntactically valid but it recommends to double check it for typos. An example without regexps: <?php if (eregi($normal, $email)) { echo("The address $email is valid and looks normal."); } else if (eregi($validButRare, $email)) { echo("The address $email looks a bit strange but it is syntactically valid. You might want to check it for typos."); } else { echo("The address $email is not valid."); } ?> The full article with the regexps and demo can be found at http://www.iki.fi/markus.sipila/pub/emailvalidator.php ---- Server IP: 62.237.7.3 Probable Submitter: 80.221.31.179 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.eregi.php Edit -- https://master.php.net/note/edit/68593 Del: integrated -- https://master.php.net/note/delete/68593/integrated Del: useless -- https://master.php.net/note/delete/68593/useless Del: bad code -- https://master.php.net/note/delete/68593/bad+code Del: spam -- https://master.php.net/note/delete/68593/spam Del: non-english -- https://master.php.net/note/delete/68593/non-english Del: in docs -- https://master.php.net/note/delete/68593/in+docs Del: other reasons-- https://master.php.net/note/delete/68593 Reject -- https://master.php.net/note/reject/68593 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#115503) next »