views:

21

answers:

1

Hello,

Is there any way to pass values between two forms. Let's say, I have two html form.

At Form 1, there's one field called name and submit button.

At Form 2, there's two field called name and email and submit button.

What I want to get is, At form 1, when i fill Form 1 name field and click submit, it will carry me to form 2 and name values that I filled will be inserted at names field of Form 2.

Is that possible to do that ?

If that so, please leave idea or snippets for me.

Thanks.

+1  A: 

if the forms are in separated pages, you can populate values in form two using the $_POST arrays:

page 1

<form action="page2.php" method="post">
name <input type="text" name="name" /><br/>
email <input type="email" name="email" />
<input type="submit" value="submit"/>
</form>

At page2.php, grab values comming from $_POST and populate the form with these values:

<?php
    $name = $_POST['name'];
    $email = $_POST['email'];
?>
<form action="pageX.php" method="post">
name <input type="text" name="name" value="<?php echo $name;?>"/><br/>
email <input type="email" name="email" value="<?php echo $email;?>"/>
<input type="submit" value="submit"/>
</form>

Obviously you'll need to validate $_POST data in page2.php, but that's another issue...

clinisbut
thanks for the quick response. I will try it out now. Thank you.
knightrider
thanks it works.
knightrider