/    Sign up×
Community /Pin to ProfileBookmark

Problems with a multi page form

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>

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogOct 07.2004 — I think your problem is in quoting...
[code=php]$fieldForwarder .= "<input type="hidden" name="$n" value="" . htmlentities(stripslashes($v)) . "">n";[/code]
...needs to be changed to one of these two options, so that the quotes within the echo's quotes aren't confused with the quotes that surround the whole expression:
[code=php]
$fieldForwarder .= "<input type="hidden" name="$n" value="" . htmlentities(stripslashes($v)) . "">n";
/* or */
$fieldForwarder .= "<input type='hidden' name='$n' value='" . htmlentities(stripslashes($v)) . "'>n";
[/code]

PS: Using an editor with syntax-highlighting can help you see these things more easily (as can surrounding your code sample here with [b]php[/b] and [b]/php[/b] [url=http://www.webdeveloper.com/forum/misc.php?action=bbcode#buttons]vB Code tags[/url]).
Copy linkTweet thisAlerts:
@ohhhhh_noauthorOct 08.2004 — Thanx for quick reply. I also found another error. Now the change of pages works. But it doesnt show me my input data on the last page.

Can you guys gimme me another aid???

Thanx
Copy linkTweet thisAlerts:
@NogDogOct 08.2004 — It looks like your field_forwarder() function returns a set of hidden input form fields for all the current $_POST array values. This is not what you want displayed (they're hidden, after all). I think you want something like this:

final.php:
[code=php]
<HTML>
<HEAD>
<TITLE>Multi-page Form - Final</TITLE>
</HEAD>
<BODY>
<p>You filled in:</p>
Name: <?php echo $_POST['cust_name']; ?><BR>
Email: <?php echo $_POST['cust_email']; ?><BR>
Address: <?php echo $_POST['cust_address']; ?><BR>
Phone: <?php echo $_POST['cust_phone']; ?><BR>
</BODY>
</HTML>
[/code]
Copy linkTweet thisAlerts:
@ohhhhh_noauthorOct 11.2004 — I had the idea to forward the data to a mailer page like:

<title>FORM</title>

<?php

include ('fieldforwarder.php');

if ($cust_name=="" || $cust_email=="" || $cust_address=="" || $cust_phone=="") { echo "Please check your input data!";

exit;}

$recipient = "[email protected]";

$about = "form";

$message = "" ;

mail($recipient, $about, $message, "FROM: multi page form");

?>

How can I insert the parts in the §message fields? If I do it like this nName: $name I receive a mail with an empty name field.

Greets
×

Success!

Help @ohhhhh_no spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...