Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New Coder
    Join Date
    Feb 2011
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    how to Post values from one form to another form?

    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?

  • #2
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    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.
    Last edited by bullant; 03-22-2011 at 08:54 AM.

  • #3
    New Coder
    Join Date
    Feb 2011
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Can u give sample code for that?

  • #4
    Regular Coder
    Join Date
    May 2008
    Location
    Michigan
    Posts
    216
    Thanks
    10
    Thanked 1 Time in 1 Post
    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
    Code:
    <form action="child2.php" method="post">
    <input type="text" id="pdetails2" name="text2" value=""/>
    <input type="submit" value="Submit"/>
    </form>
    child2.php
    PHP Code:
    <?php

    $text2 
    $_REQUEST['text2'];

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

  • #5
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by bullant View Post
    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

  • #6
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by nicky View Post
    Send the form to a PHP page that requests the variables submitted, then you can "echo" the variables.

    parent.html
    Code:
    <form action="child2.php" method="post">
    <input type="text" id="pdetails2" name="text2" value=""/>
    <input type="submit" value="Submit"/>
    </form>
    child2.php
    PHP Code:
    <?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

  • #7
    Regular Coder
    Join Date
    May 2008
    Location
    Michigan
    Posts
    216
    Thanks
    10
    Thanked 1 Time in 1 Post
    Quote Originally Posted by oesxyl View Post
    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.

  • #8
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by nicky View Post
    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'.

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


    best regards

  • #9
    Regular Coder
    Join Date
    May 2008
    Location
    Michigan
    Posts
    216
    Thanks
    10
    Thanked 1 Time in 1 Post
    Quote Originally Posted by oesxyl View Post
    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'.

    Edit: 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.

  • #10
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by nicky View Post
    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

  • #11
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    Quote Originally Posted by oesxyl View Post
    why to use get when op already use post?

    best regards
    The op put their request in the Client side development forum so I am assuming they prefer a client side solution which doesn't involve php or other server side languages.

  • #12
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by prabakaranac05 View Post
    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?

    Quote Originally Posted by bullant View Post
    The op put their request in the Client side development 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

  • #13
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    Quote Originally Posted by oesxyl View Post
    you can't use post in a solution on the client side?

    best regards
    That's why I suggested using GET


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •