<html>
<head>
<title>Validator Test Program</TITLE>
</head>
<BODY>
<?
// Just display the form variables
foreach ( $_POST as $key => $val ) {
echo ( "<br>POST: key=$key value=$val" );
}
?>
<?
require_once ( "Validator.php" );
$valid = new Validator ( "USEREDIT" );
$valid->addExists ( "fldFirstName", "First Name" );
$valid->addExists ( "fldLastName", "Last Name" );
$valid->addExists ( "fldEmail", "Email" );
$valid->addEmail ( "fldEmail" );
$valid->addCopy ( "fldFirstName", "fldPreferedName" );
$valid->addExists ( "fldPassword", "Password must exist" );
$valid->addEqual ( "fldPassword", "fldPassword_CHK", "Passwords must be the same" );
// This form var does not exist
$valid->addExists ( "nonExistFormVar", "NonExist" );
// Add this if you want to be alerted to missing form variables
// probably good for a debug mode
//$valid->setMissingAlert ( TRUE );
echo $valid->toHtml ();
?>
<form name="USEREDIT" action="valtest.php" method="post">
<table border=1 cellspacing=0 cellpadding=0>
<TR>
<TD nowrap >First Name</TD>
<TD><input type="text" name="fldFirstName"></TD>
</TR>
<TR>
<TD nowrap >Last Name</TD>
<TD><input type="text" name="fldLastName"></TD>
</TR>
<TR>
<TD nowrap >Prefered Name</TD>
<TD><input type="text" name="fldPreferedName"></TD>
</TR>
<TR>
<TD nowrap >Email</TD>
<TD><input type="text" name="fldEmail"></TD>
</TR>
<TR>
<TD colspan=2>
Note: Passwords here should be type <i>password</i> but for this example just text will do
</TD>
</TR>
<TR>
<TD nowrap >Password</TD>
<TD><input type="text" name="fldPassword"></TD>
</TR>
<TR>
<TD nowrap >Reenter Password</TD>
<TD><input type="text" name="fldPassword_CHK"></TD>
</TR>
<TR>
<TD colspan=2>
<input type="submit" name="UserEdit_Action" value="Update" <? echo $valid->onSubmit(); ?>>
</TD>
</TR>
</table>
</form>
</BODY>
<html>
|