Forum Moderators: coopster
I have been using the script below to take the fields in my first form and 'echo' them in my second form.
======================================================
This is the code
======================================================
<?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()
$nexturl = "http://www.unicomcomputers.com/orderform.htm" ;
header( "Location: $nexturl" );
?>
======================================================
End of the code
======================================================
On my second page I have the following code in the form tags and above any other fields.
======================================================
<?php echo field_forwarder();
======================================================
All the fields on the second page are sent correctly, however these fields are sent by a second php script that I have used many times with success. Part of the code is shown below, this is the part where it looks for certain fields to be sent. The top two 'field_forwarder' and 'computer' are my feeble attempts at making the script look for the 'echoed' hidden fields from the first form. So far this has not worked.
======================================================
$field_forwarder = $_POST['extras'] ;
$computer = $_Post['computer'] ;
$name = $_POST['name'] ;
$company = $_POST['company'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
$tel = $_POST['tel'] ;
$referal = $_POST['referal'] ;
$http_referrer = getenv( "HTTP_REFERER" );
======================================================
Sorry for the long post. I hope that I have clearly outlined the problem that I am having.
I would really appreciate any help that, anyone can give on this.
Thanks,
Paul
have you seen in this line:
$computer = $_Post['computer'];
that it should be written uppercase?:
$computer = $_POST['computer'];
anyway with a simple
echo("<pre>".htmlspecialchars(print_r($GLOBALS,true))."</pre>"); you can output ANY variable and it's value. this is your friend to analyze such problems.