该库不需要表单的名称。如果您查看他们给您的示例,他们只使用输入字段的名称。
<?PHP
require_once "formvalidator.php";
$show_form=true;
if(isset($_POST['Submit']))
{
$validator = new FormValidator();
$validator->addValidation("Name","req","Please fill in Name");
$validator->addValidation("Email","email",
"The input for Email should be a valid email value");
$validator->addValidation("Email","req","Please fill in Email");
if($validator->ValidateForm())
{
echo "<h2>Validation Success!</h2>";
$show_form=false;
}
else
{
echo "<B>Validation Errors:</B>";
$error_hash = $validator->GetErrors();
foreach($error_hash as $inpname => $inp_err)
{
echo "<p>$inpname : $inp_err</p>\n";
}
}
}
if(true == $show_form)
{
?>
<form name='test' method='POST' action='' accept-charset='UTF-8'>
Name: <input type='text' name='Name' size='20'>
Email: <input type='text' name='Email' size='20'>
<input type='submit' name='Submit' value='Submit'>
</form>
<?PHP
}//true == $show_form
?>
表格的名称是“测试”。它没有被检查。请发布您的源代码,以便有人可以帮助您找到问题所在。
您还可以查看以下帖子以获取更多库 - PHP 最简单的表单验证库?