i have easier version to check a posted value, its just an example, maybe has syntax errors, but you could think that more:
here is a schematic example, with ideas:
<?
create_field($value,$form_type)
{
if($form_type=="checkbox")
print "checkbox with a field name:".$value." and using a value, stored in session:".$_SESSION["$value"];
if($form_type=="textfield")
{
if(strstr($value,"pass"))
print "a textfield as a password, with a field name:".$value ;
else
print "a textfield as a textfield, with a field name:".$value." and using a value, stored in session";
}
if($form_type=="list")
print "make a dropdown list, from a table name called $value(from database), and using a value, stored in session:".$_SESSION["$value"];
}
check_field($value,$field_check_types)
{
//it creates check, string checks...
if(strstr($field_check_types,"required"))
{
if(emty($_POST["$value"]))
$errors[]="$value field must have been filled";
}
if(strstr($field_check_types,"letters_only"))
{
if(isset($POST["$value")) {
if( !ereg([A-Za-z]*$" , $POST["$value"]))
$errors[]="$value field must contains letters only";
}
}
if(strstr($field_check_types,"number"))
{
if(gettype($_POST["$value"])!="integer"))
$errors[]="$value field must been an integer";
}
// you could do here several syntax check..
return($errors);
}
?>
if($_POST)
{
$errors.=check_field("username","letters_only");
$errors.=check_field("password","letters_only");
...........
if($errors=="")
{
//lets insert the data into database...
$result=insert_db("username","password","email");
}
}
and you make fields like this:
print "<form...............>";
create_field("username","textfield");
create_field("password","textfield");
create_field("email","textfield");
print "</form...............>";