Hey guys,
I try to get a multi page form working… Though I am a php grub I would need your help. The browers allways returns the following error mesage: [Parse error: parse error, unexpected T_STRING in /homepages/1/d81319025/htdocs/1/fieldforwarder.php on line 49]
Thanx for your help
sources:
fieldforwarder.php
<?php
function field_forwarder(){
global $_POST, $rEM979, $FFoutputType;
//get the arguments passed
$argList = func_get_args();
//globalize any other set of instructions
if(count($argList)){
eval(‘global $’ . $argList[count($argList)-1] . ‘;’);
}
//set the default set of values to convert
if(count($argList)==0){
//if the function is initially passed without parameter we’re looking in $_POST
$argList[0] = ‘_POST’;
$startValue = $_POST;
if(sizeof($startValue)==0){return false;}
}elseif(count($argList)==1){
eval( ‘$rEM979[“‘ . $argList[0] . ‘”] = $’ . $argList[0] . ‘;’);
$argList[0] = ‘rEM979’;
$startValue = $rEM979;
}elseif(count($argList)==2){
eval( ‘$startValue = $’ . $argList[1] . ‘[“‘ . $argList[0] . ‘”];’);
}else{
for($e=count($argList)-2;$e>=0;$e–){
$intersperse .= ‘[“‘ . $argList[$e] . ‘”]’;
}
eval( ‘$startValue = $’ . $argList[count($argList)-1] . $intersperse . ‘;’);
}
foreach($startValue as $n => $v){
if(is_array($v)){
//call the function again
$shiftArguments = ”;
for($w=0;$w<=count($argList)-1;$w++){
$shiftArguments .= ‘”‘ . $argList[$w] . ‘”, ‘;
}
$shiftArguments = substr($shiftArguments, 0, strlen($shiftArguments)-2);
eval(‘$fieldForwarder .= field_forwarder(“‘ . $n . ‘”‘ . substr(‘,’,0,strlen($shiftArguments)) . ‘ ‘ . $shiftArguments . ‘);’);
}else{
//we have an root value finally
if(count($argList)==1){
//actual output
flush();
if($FFoutputType == ‘print’){
$fieldForwarder .= “$$n = ‘$v’;n”;
}else{
$fieldForwarder .= “<input type=”hidden” name=”$n” value=”” . htmlentities(stripslashes($v)) . “”>n”;
}
}elseif(count($argList)>1){
$indexString = ”;
for($g=count($argList)-3;$g>=0;$g–){
$indexString .= ‘[‘ . ((!is_numeric($argList[$g]) and $FFoutputType==’print’)?”‘”:”) .
$argList[$g] . ((!is_numeric($argList[$g]) and $FFoutputType==’print’)?”‘”:”) . ‘]’;
}
$indexString .= ‘[‘ . ((!is_numeric($n) and $FFoutputType==’print’)?”‘”:”) .
$n . ((!is_numeric($n) and $FFoutputType==’print’)?”‘”:”) . ‘]’;
//actual output
flush();
if($FFoutputType == ‘print’){
$fieldForwarder .= “${$argList[count($argList)-2]}$indexString = ‘$v’;n”;
}else{
$fieldForwarder .= “<input type=”hidden” name=”{$argList[count($argList)-2]}$indexString” value=”” . htmlentities(stripslashes($v)) . “”>n”;
}
}
}
}
return $fieldForwarder;
}//end field_forwarder()
?>
form1.php:
<HTML>
<HEAD>
<TITLE>Multi-page Form – Page One</TITLE>
</HEAD>
<BODY>
<p>Please fill in the following information</p>
<FORM METHOD=”POST” ACTION=”form2.php”>
Name: <INPUT TYPE=”text” SIZE=”40″ name=”cust_name”><BR>
Email: <INPUT TYPE=”text” SIZE=”40″ name=”cust_email”><BR>
<INPUT TYPE=”submit” name=”submit1″ value=”Proceed”>
</FORM>
</BODY>
</HTML>
form2.php:
<?php
include (‘fieldforwarder.php’);
?>
<HTML>
<HEAD>
<TITLE>Multi-page Form – Page Two</TITLE>
</HEAD>
<BODY>
<p>Please fill in the following information</p>
<FORM METHOD=”POST” ACTION=”final.php”>
Address: <INPUT TYPE=”text” SIZE=”50″ name=”cust_address”><BR>
Phone: <INPUT TYPE=”text” SIZE=”20″ name=”cust_phone”><BR>
<?php echo field_forwarder(); ?>
<INPUT TYPE=”submit” name=”submit2″ value=”Proceed”>
</FORM>
</BODY>
</HTML>
final.php:
<?php
include (‘fieldforwarder.php’);
?>
<HTML>
<HEAD>
<TITLE>Multi-page Form – Final</TITLE>
</HEAD>
<BODY>
<p>You filled in:</p>
Name: <?php echo field_forwarder(); ?><BR>
Email: <?php echo field_forwarder(); ?><BR>
Address: <?php echo field_forwarder(); ?><BR>
Phone: <?php echo field_forwarder(); ?><BR>
</BODY>
</HTML>