...

View Full Version : how to Post values from one form to another form?



prabakaranac05
03-22-2011, 07:37 AM
parent.html<HTML> <form name="form" method="post" action="child2.html"> <input type="text" value="" name="text2" id="pdetails2"> <input type=submit name="submit" value="submit"></form> </html>

child2.html
<HTML> <form name="form1"> <input type="text" value="" name="text3" id="pdetails3"> </form><html>

here if i give any value in parent form text box once i click on submit button i need that text box valu in child2 form textbox what can i do?

bullant
03-22-2011, 07:51 AM
You can use cookies (which can be switched off by the user) or send the form data as a GET to the 2nd window and parse the query string in the second window to put the values in the appropriate boxes.

prabakaranac05
03-22-2011, 08:04 AM
Can u give sample code for that?

nicky
03-22-2011, 04:12 PM
Send the form to a PHP page that requests the variables submitted, then you can "echo" the variables.


parent.html<HTML> <form name="form" method="post" action="child2.html"> <input type="text" value="" name="text2" id="pdetails2"> <input type=submit name="submit" value="submit"></form> </html>

parent.html


<form action="child2.php" method="post">
<input type="text" id="pdetails2" name="text2" value=""/>
<input type="submit" value="Submit"/>
</form>


child2.php


<?php

$text2 = $_REQUEST['text2'];

echo "This is from the form: $text2";
?>

oesxyl
03-22-2011, 04:14 PM
You can use cookies (which can be switched off by the user) or send the form data as a GET to the 2nd window and parse the query string in the second window to put the values in the appropriate boxes.
why to use get when op already use post?

best regards

oesxyl
03-22-2011, 04:20 PM
Send the form to a PHP page that requests the variables submitted, then you can "echo" the variables.

parent.html


<form action="child2.php" method="post">
<input type="text" id="pdetails2" name="text2" value=""/>
<input type="submit" value="Submit"/>
</form>


child2.php


<?php

$text2 = $_REQUEST['text2'];

echo "This is from the form: $text2";
?>

agree and is correct but that $_REQUEST is a invitation to mix get and post and then mess things somewhere.

another method, without submit of the first form get the value using javascript, using onblur event of the input, and add a input hidden to the second form.

best regards

nicky
03-22-2011, 04:31 PM
agree and is correct but that $_REQUEST is a invitation to mix get and post and then mess things somewhere.

When I use $_POST, it doesn't work, so I'm accustomed to using $_REQUEST.

oesxyl
03-22-2011, 04:41 PM
When I use $_POST, it doesn't work, so I'm accustomed to using $_REQUEST.
In this case $_GET will do same thing, :)
IMO is something wrong in the way you pass the values. In a form you need to have attribute action 'post' and you can't pass arguments thrue a url like ?x=y because this is a 'get'.

maybe sometime, when you have this problem and need to solve it, you can post to see what's wrong

best regards

nicky
03-22-2011, 04:44 PM
In this case $_GET will do same thing, :)
IMO is something wrong in the way you pass the values. In a form you need to have attribute action 'post' and you can't pass arguments thrue a url like ?x=y because this is a 'get'.

maybe sometime, when you have this problem and need to solve it, you can post to see what's wrong

I don't use get as my method because it's a vulnerable security issue. I always use post.

oesxyl
03-22-2011, 05:08 PM
I don't use get as my method because it's a vulnerable security issue. I always use post.
what? this is weird, :)
1. vulnarability is in your code not in the action method, sanitize the input
2. if somebody 'evil' know what to do with 'get' be sure he know to do same thing with 'post'
3. if somebody 'evil' don't know what to do with posts arguments, is no danger, 'get' is as safe as 'post', :)

this make me think that your problem could be in server settings, :)

best regards

bullant
03-22-2011, 11:00 PM
why to use get when op already use post?

best regards

The op put their request in the Client side development (http://www.codingforums.com/forumdisplay.php?f=1) forum so I am assuming they prefer a client side solution which doesn't involve php or other server side languages.

oesxyl
03-23-2011, 01:20 AM
parent.html<HTML> <form name="form" method="post" action="child2.html"> <input type="text" value="" name="text2" id="pdetails2"> <input type=submit name="submit" value="submit"></form> </html>

child2.html
<HTML> <form name="form1"> <input type="text" value="" name="text3" id="pdetails3"> </form><html>

here if i give any value in parent form text box once i click on submit button i need that text box valu in child2 form textbox what can i do?
you didn't seen this? :)


The op put their request in the Client side development (http://www.codingforums.com/forumdisplay.php?f=1) forum so I am assuming they prefer a client side solution which doesn't involve php or other server side languages.
you can't use post in a solution on the client side?

best regards

bullant
03-23-2011, 01:35 AM
you can't use post in a solution on the client side?

best regards

That's why I suggested using GET



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum