|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-03-30 02:40 UTC] webmaster at crescentart dot com
Since I have been using php I have had a problem with the ereg function not mathcing patterns properly.
For example I am trying the use ereg to ensure that users use passowrds that contain a combination of letters and numbers.
These are my HTML and PHP codes:
<input type="password" name="password">
if(!ereg("([a-zA-Z0-9])", "$password")){
echo "Bad Password";
}
The problem that I encounter with ereg is that I have been able to enter passwords from the html form that do not contain numbers and or only have mixed case letters but ereg IF statment does match the pattern and echo "Bad Password".
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 03:00:01 2025 UTC |
You regex only matches on character. append a '+' at the end of the character-class modifier, e.g. if (!eregi('^[a-z0-9]+$', ...I have tried using your suggestion and I am still having a problem with ereg and eregi allowing entries with out numbers. if(!eregi("^[a-z0-9]+$", "$pass")){ die("Your passowrd does not meet security requirments. Use your back button to make corrections."); }