www.webdeveloper.com
Results 1 to 9 of 9

Thread: Submit 2 Pages of Info to 1 MySQL Table

  1. #1
    Join Date
    Aug 2008
    Posts
    31

    Submit 2 Pages of Info to 1 MySQL Table

    Hi,

    I've seen long registration forms broken up into two pages. How can I have one page submit info to a table, and then another page submit more info in the same table?

    Any help is appreciated.
    Thanks in advance.

  2. #2
    Join Date
    Jul 2007
    Location
    Wisconsin
    Posts
    468
    you can pass the values from the first page to the second page, and then pass all the values at once to MySQL; no need to write twice.

  3. #3
    Join Date
    Aug 2008
    Posts
    31
    Yea but the pages won't be right after each other. I have one page were people can go to at a later date. Sorry I should have specified that.

  4. #4
    Join Date
    Jul 2007
    Location
    Wisconsin
    Posts
    468
    Well, can you not write to the db from both pages then?
    Is the second page gong to replace/update things from the first page?
    The more details you can share now, the easier it is for us to help.

  5. #5
    Join Date
    Aug 2008
    Posts
    31
    The second page doesn't replace anything in the db. It only replaces the nulls that automatically fill in after the first page gets submitted. I just dont know how to insert the second page of data to the same user's row. If thats unclear let me know.

  6. #6
    Join Date
    Jul 2007
    Location
    Wisconsin
    Posts
    468
    PHP Code:
    $sqlUpdate "UPDATE `table` SET `column1` = ' " $_POST['name'] ." ', `column2` = ' " $_POST['instruction'] . " ' WHERE `rowID` = ' " $_POST['rowID'] ." ' "
    Then again, actually see what you have for a form code would make it a whole lot easier to understand.
    Last edited by OctoberWind; 02-18-2009 at 09:34 AM. Reason: quotaions: yea, you dont have to open/close so many singles/doubles, but still... it works...

  7. #7
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    700
    Or you could create one big form, which you split into several hidden divs, which you then use dhtml to hide or show.

    While the initial page will take a little longer to load, overall, the solution will be much faster (and therefore nicer to use) because it's not using bandwidth to pass, and then re-pass variable values from one form to the next. When the user clicks on [Next], the next page of the form will appear instantly, and your user can switch seamlessly between pages of your form without you having to worry about any coding at all.

    The two downsides to this are a)dealing with browsers that don't have javascript, and b)dealing with branched forms (that is, forms that change for the next page according to some value set in the last).
    CTB

  8. #8
    Join Date
    Aug 2008
    Posts
    31
    Update function is perfect! one question. You mentioned earlier that i could pass the values. I can pass the values just fine but once the second page is filled out how do i submit all the values? Would this be right:

    first page with first form:
    HTML Code:
    <html>
    <body>
    <form action="second.php" method="post"> 
    <input name="first" type="text" /> 
    <input type="submit" />
    </form>
    </body>
    </html>
    second.php(second page with second form):
    PHP Code:
    <html>
    <body>
    <?php
    $first 
    $_POST['first'];
    ?>

    <form action="process.php" method="post"> 
    <input name="second" type="text" /> 
    <input type="submit" />
    </form>
    </body>
    </html>
    process.php:
    PHP Code:
    <?php
    $_POST
    [$first];
    $second $_POST['second'];
    ?>
    Im kind of new to php so.

    chestertb, i was originally going to do that but, like you said, i need to use value of the first page in order to continue with the next.

  9. #9
    Join Date
    Aug 2008
    Posts
    31
    Nevermind, I got it! Thanks for all your help

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles