Re: Validation function doesn't work (sort of...)
| From: | David Grant | Date: | Tue, 27 May 2003 16:07:01 +0000 |
| Subject: | Re: Validation function doesn't work (sort of...) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-149139@lists.php.net to get a copy of this message | ||
Jason Lange wrote:
for ($i = 0; $i < $vCount; ++$i) {
if (($cryptUser === $validUser[$i]) &&
($cryptPass === $validPass[$i])) {
$retVal = true;
+ break;
} else {
$retVal = false;
}
}
return $retVal; // return true if valid false otherwise
You MUST call the return function in order to escape from the loop (or use a break statement as above), as Jonathan pointed out.
As for the === comparison, I don't believe there is an problem, as will ALWAYS return a string.
Regards,
David
--
David Grant
Web Developer
david.grant@wiredmedia.co.uk
http://www.wiredmedia.co.uk
Tel: 0117 930 4365, Fax: 0870 169 7625
Wired Media Ltd
Registered Office: 43 Royal Park, Bristol, BS8 3AN
Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD
Company registration number: 4016744
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************