test.php
<form action = "test1.php" method = "POST">
<p>
<b>Interests: </b>
<br>
<input type = "Checkbox" name = "interests[]" value =
"politics">Poli tics
<input type = "Checkbox" name = "interests[]" value =
"economy">Econo my
<p>
<input type = "Submit" name = "submit" value = "Save">
</form>
</form>
text1.php:
<?
include("test2. php");
$fp = new FormProcessor() ;
$fp->valid(
"interests" ,
"array",
LETTERS,
'The interests are valid.',
'The interests are invalid!'
);
?>
test2;php
<?
define('LETTERS ', '/^[-+]?\\b[a-zA-Z]*\\.?[a-zA-Z]+\\b$/');
class FormProcessor
{
private function getValue($field )
{
if($field == "interests" )
{
echo $field;
echo $value;
}
global ${$field};
return ${$field};
}
public function valid($field, $type, $pattern, $warn, $alert)
{
$value = $this->getValue($fiel d);
}
}
?>
<form action = "test1.php" method = "POST">
<p>
<b>Interests: </b>
<br>
<input type = "Checkbox" name = "interests[]" value =
"politics">Poli tics
<input type = "Checkbox" name = "interests[]" value =
"economy">Econo my
<p>
<input type = "Submit" name = "submit" value = "Save">
</form>
</form>
text1.php:
<?
include("test2. php");
$fp = new FormProcessor() ;
$fp->valid(
"interests" ,
"array",
LETTERS,
'The interests are valid.',
'The interests are invalid!'
);
?>
test2;php
<?
define('LETTERS ', '/^[-+]?\\b[a-zA-Z]*\\.?[a-zA-Z]+\\b$/');
class FormProcessor
{
private function getValue($field )
{
if($field == "interests" )
{
echo $field;
echo $value;
}
global ${$field};
return ${$field};
}
public function valid($field, $type, $pattern, $warn, $alert)
{
$value = $this->getValue($fiel d);
}
}
?>