php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16358 Problem with ereg
Submitted: 2002-03-30 02:40 UTC Modified: 2002-03-31 22:04 UTC
From: webmaster at crescentart dot com Assigned:
Status: Not a bug Package: *Regular Expressions
PHP Version: 4.1.2 OS: Linux Red HAt 7.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: webmaster at crescentart dot com
New email:
PHP Version: OS:

 

 [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".

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-30 03:48 UTC] sander@php.net
The bug system is not the appropriate forum for asking support
questions. For a list of a range of more appropriate places to ask
for help using PHP, please visit http://www.php.net/support.php


 [2002-03-30 05:44 UTC] mfischer@php.net
You regex only matches on character. append a '+' at the end of the character-class modifier, e.g.
if (!eregi('^[a-z0-9]+$', ...
 [2002-03-30 15:33 UTC] webmaster at crescentart dot com
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.");

}
 [2002-03-31 05:46 UTC] sander@php.net
This is NOT a support forum!
 [2002-03-31 22:04 UTC] webmaster at crescentart dot com
I have found the error in my ereg script. Please discregard the bug report that I submitted.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 04:01:25 2019 UTC