Hi, i am making 3 forms, let's say, form1, form2, form3.
In form1, there is a field "givenname" and a submit button that link to form2, and i want to pass this field to form2, i can pass this without any difficulty.
However, i also want to pass the field from form1 to form3.
And i cannot get the value from form1 to form 3.

Can anyone help?

here's the code:
form1.php:

<form name="myform" action="form2.php" method="post">

<table>

<tr><td>Given Name</td><td><input type="text" name="given name" id="given name"></td></tr>

</table>




<table>

<tr><td><input type="submit" name="submit" value="submits"></td></tr>

</table>


</form>

form2.php:

<form name="myform" action="form3.php" method="post">

<table>

<tr><td>Test</td></tr>

<tr><td>
<?php
$givenname = $_REQUEST['given_name'];
if($givenname!="" ) {
   echo("Given Name: " .$givenname ."<br>");
}
?>
</td></tr>

</table>



<table>

<tr><td><input type="submit" name="submit" value="submit"></td></tr>

</table>


</form>

form3.php:

<form name="myform" method="post">

<table>

<tr><td>Last Form</td></tr>

<tr><td>
<?php
$givenname = $_REQUEST['given_name'];
if($givenname!="" ) {
   echo("Given Name: " .$givenname ."<br>");
}
?>
</td></tr>

</table>


</form>

The PHP code in form3.php can not work.
Can anyone help?
thanks

Hi,

you need at least a hidden input type in form2 to hold the value which will be passed to the form3. Now you do not pass any value to form3 you only print it.

oh yeah, it is true that i just want to print it.

But i get what you meant.
So i should generate hidden input that have the value from form1, and then from form3, take the hidden value from form2, isn't it?

hmm, how can it be done?
i don;t have any idea..

you use an input type text to pass the value from form1 to form2. You need a input into form2 to pass the value to form3

add this code to the form2.php to the form

<input type="hidden" name="given_name" value="<?php echo $givenname ?>">

in form3 if you press submit it will dissapear again. you need to put the line into Form3 also to stay there but that is OT.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.