[SOLVED] ValidationServerFunction in forms class trouble
Posted: Tue Jul 27, 2004 6:06 pm
I have a class which I use with all my database user related functions. Within that class I have a UserExists() function, which is passed the username and returns true if the user exists and false if not. The class encapsulates all the database calls, etc., so I don't have to fool with it. So, I've created a wrapper function which essentially reverses the return to work with the ValidationServerFunction. For example:
Here is the UserIsUnique function:
The problem is I keep getting the "Fatal error: Call to a member function on a non-object in xxxx" error message referring to the line which contains the $myclasslib->UserExists call. I clearly initialize the class How do I fix this?
Code: Select all
$registration->AddInput(array(
"TYPE"=>"text",
"NAME"=>"username",
"ID"=>"username",
"TABINDEX"=>1,
"MAXLENGTH"=>20,
"SIZE"=>40,
"ValidateRegularExpression"=>"^[a-zA-Z0-9]+$",
"ValidateRegularExpressionErrorMessage"=>"The username may only contain letters and digits.",
"ValidateAsNotEmpty"=>1,
"ValidateAsNotEmptyErrorMessage"=>"Please enter a valid username.",
"ValidateMinimumLength"=>3,
"ValidateMinimumLengthErrorMessage"=>"Your username must be at least 3 characters long.",
"LABEL"=>$registrationfields['username'],
"ValidationServerFunction"=>"UserIsUnique",
"ValidationServerFunctionErrorMessage"=>"That username already is being used. Please choose another username.",
"ValidateOnlyOnServerSide"=>1
));Code: Select all
require("myclasslib.php");
$myclasslib = new MyClassLib();
function UserIsUnique($username)
{
$return = $myclasslib->UserExists($username);
if ($return == 0)
return true;
else
return false;
}