Tis a tad easier than that. function match_str($str1, $str2) { if ($str1 == $str2) return true; else return false; }
// If the fields don't match exit with error. if (!match_str($field1, $field2)) { echo "The fields must match."; exit; } -Kevin ----- Original Message ----- From: "Jeff Field" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, May 23, 2002 2:09 PM Subject: [PHP] matching two form fields function? > 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 > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php