Hello everybody,
I'm working on a class but having a lot of problems... probably my understanding of PhP-OOP is not so good ...
Here's the class: I found it on the web and I've tried to personalize it to fit my needs...

<?php

class FormV
{
var $errorList;
function FormV()
{
$this->reset_errorList();
}
function getValue( $field )
{
$value = $HTTP_POST_VARS[ $field ];
return $value;
}
function isEmpty( $field, $msg )
{
$value = $this->getValue( $field );
if( trim( $value ) == "" )
{
$this->errorList[] = array( "field" => $field, "value" => $value, "msg" => $msg );
return true;
} else
return false;
}
function isString( $field, $msg )
{
$value = $this->getValue( $field );
if( is_string( $value ) )
return true;
else
{
$this->errorList[] = array( "field" => $field, "value" => $value, "msg" => $msg );
return false;
}
}
function isEmail( $field, $msg )
{
$value = $this->getValue( $field );
$pattern = "/^([a-zA-Z0-9])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/";
if( preg_match( $pattern, $value ) )
return true;
else
{
$this->errorList[] = array( "field" => $field, "value" => $value, "msg" => $msg );
return false;
}
}
function isError()
{
if( sizeof( $this->errorList ) > 0 )
return true;
else
return false;
}
function get_errorList()
{
return $this->errorList;
}
function reset_errorList()
{
$this->errorList = array();
}
function stringConvert( $field )
{
$value = $this->getValue( $field );
$value = html_special_chars( $value );
$value = stripslashes( $value );
$value = strtolower( $value );
return $value;
}
};

?>

Ok.
I think that the getter is *totally* wrong but I'm not able to debug it, because it's private (I think...). Also the stringConvert() method sucks, maybe I'll split it in some others accessor methods, for a better design.
Now I'm totally lost, I don't have a clue how to continue, I've tried for hours and hours to make it work, but didn't succeed :(
Any suggestion on improving and other enhancment for a good form validating class is really really appreciated.

TIA,
Nicholas

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to