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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Continuous forms

    I am trying to create a form that when submitted will then route to another form asking form more information. My questions is how shoudl those forms be linked? i.e. Form 1 asks for and id number, first name, and last name, the user clicks submit and the second form asks for an address. The address is saved in a separate table in the database but uses the same id number without asking for it.

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    2,958
    Thanks
    2
    Thanked 304 Times in 296 Posts
    If you only have a small amount of data that needs to be passed between pages, using a hidden field in the form is a popular method. If you have a large amount of data, this should be kept on the server and passed between pages in session variables.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,374
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    With PHP, the first form has the name of the second form in the spot
    for action: <form action="script2.php" method="post">

    On the second script, you grab the variables from the first form.

    <?php
    $name=$_REQUEST['name'];
    $id=$_REQUEST['id'];
    ?>
    Then display the next form.

    That 2nd form can call another script or you can call the final
    PHP script that processes your form(s).

    With PHP, variables are global, so as you move from script to script,
    those variables ($name, $id, etc) will follow along. No need to send
    them hidden or re-define them.


  •  

    Posting Permissions

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