matching two form fields function?

From: Date: Thu, 23 May 2002 20:09:29 +0000
Subject: matching two form fields function?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-98983@lists.php.net to get a copy of this message
I feel bad about asking a question like this, but I've spent quite a bit of time trying to track down what should be a simple answer and, no luck. Anyway... I'm trying to create a simple function that will match two form fields against each other, e.g. "Email" equals "Repeat Email". The following function seems to work, however, I'm a little uncomfortable because I don't understand it. Specifically, I don't understand why returning $str1 by itself (or $str2 by itself) makes it work. --------------------------------------------- /* checks two fields against each other to make sure they match and if they don't match it throws an error message into the $err_text array */ function CheckMatch($str1, $str2, $name) { global $err_text; $match = ($str1 == $str2); if ($match != true) { $err_text[] = "$name must match."; } return $str1; } --------------------------------------------- Any help is appreciated! Thanks! Jeff

« previous php.general (#98983) next »