Re: problems with strchr...

From: Date: Tue, 05 Sep 2000 01:50:53 +0000
Subject: Re: problems with strchr...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-15201@lists.php.net to get a copy of this message
On 4 Sep, Juan Luis Baptiste M. wrote: > I have a function to verify if a string has invalid characters or not, > this is the function: > > function verifyUser($login) > { > // $login=stripslashes($login); > $n= strlen($login); > if (($n >= 4) && ($n <= 12)) > if ((strchr($login,'!')!=false) && > (strchr($login,'"')!=false) > && (strchr($login,'|')!=false) && > (strchr($login,'º')!=false) && > (strchr($login,'\\')!=false) && > (strchr($login,'#')!=false) && (strchr($login,'·')!=false) > && > (strchr($login,'!')!=false) && > (strchr($login,'$')!=false) && > (strchr($login,'~')!=false) && (strchr($login,'%')!=false) > && > (strchr($login,'½')!=false) && > (strchr($login,'/')!=false) && > (strchr($login,'{')!=false) && (strchr($login,'(')!=false) > && > (strchr($login,'[')!=false) && > (strchr($login,')')!=false) && > (strchr($login,']')!=false) && (strchr($login,'=')!=false) > && > (strchr($login,'}')!=false) && > (strchr($login,'?')!=false) && > (strchr($login,'\'')!=false) && (strchr($login,'¿')!=false) > && > (strchr($login,'ñ')!=false) && > (strchr($login,'Ñ')!=false) && > (strchr($login,'`')!=false) && (strchr($login,'+')!=false) > && > (strchr($login,'+')!=false) && > (strchr($login,'\'')!=false) && (strchr($login,' > ')!=false) && (strchr($login,'ç')!=false) && > (strchr($login,',')!=false) > && > (strchr($login,'^')!=false) && > (strchr($login,'*')!=false) && (strchr($login,'Ç')!=false) > && > (strchr($login,';')!=false) && > (strchr($login,':')!=false) && > (strchr($login,'<')!=false) && > (strchr($login,'>')!=false)&& > (strchr($login,'@')!=false)) > return -1; > else > return true; > > else > return false; > } > > If I pass the string 'minickn@me' it always return true. I don't know if > the problem is my code (I suppose) or strchr, but if someone can help me > > with this thanks. > > -- > ------------------------------------- > Juan Luis Baptiste M. > > Ingeniero de Desarrollo > SANCHO/BBDO - Nextmedia Interactive > http://www.nextmedia-i.com > ------------------------------------- You are ANDing all your strchr tests, so that to return FALSE all the strchr tests must be TRUE. -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA

« previous php.general (#15201) next »