#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    23
    Rep Power
    0
    Hey, I need to setup a form that inputs submitted information into a database, but the form is in multiple pages (not optional). Because of high traffic and other factors, the information must only go into the database once every step of the form has been completed.

    So basically what I am asking is how should I go about spanning a large form over multiple pages?

    Cookies are not an option since there is a potential for over a hundred fields to fill in (which is why the form is spread over several pages in the first place).

    ------------------
    Aristotle concluded that those who admit their stupidity are truly wise.
    -
    Gil Hildebrand Jr
    4atcost.com Senior Web Developer
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    8
    Rep Power
    0
    On each page starting with the second you could run something like this to passs each variable to the next page as a hidden input:

    while(list($key, $val) = each $HTTP_POST_VARS)) {
    printf('<input type="hidden" name="%s" value="%s">', $key, $val);
    }

    By the time you get to the last page you will have all your variables available to you.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    8
    Rep Power
    0
    Sorr yshould be this
    while(list($key, $val) = each ($HTTP_POST_VARS)) {
    printf('<input type="hidden" name="%s" value="%s">', $key, $val);
    }

  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    33
    Rep Power
    14
    You can pass data from first form to second form. In the second form store data into database table and get mysql row number in which data of first form is stored. Pass row number to further forms and Update database table row with data of second, third,fourth form respectively. I know this is not the solution but just a logic. Hope this will help you.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2000
    Location
    Indiana
    Posts
    614
    Rep Power
    15
    He already said it could only be entered one time in the database. The only way to do it is with hidden fields... since you're not willing to store it on the server in any way.
  10. #6
  11. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    61
    Or you could implement a "server-side cookie" which appends key-value pairs into a temp text file with a uniquely generated filename, which you parse with regular expressions at the end to generate your SQL statement. You will need to experiment with addslashes(), and other protection mechanisms such as htmlentities().

    For that matter, instead of a plain text file you could generate a custom PHP file, to which the browser is redirected after submitting the last page. We actually used Perl to create a temporary PHP file for one of our more complicated jobs. (But, be very careful NOT to allow users to put arbitrary PHP code into the forms)

    [This message has been edited by rycamor (edited August 05, 2000).]
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Dallas, Texas USA
    Posts
    9
    Rep Power
    0
    Why not just use a simple phpform to add the information of each page. The submition would bring up the next page with the use of
    "include("http://www.somthing.com/somthing.html".
    Am I missing somthing? I do this myself?
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2000
    Location
    Indiana
    Posts
    614
    Rep Power
    15
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>
    Or you could implement a "server-side cookie" which appends key-value pairs into a temp text file with a uniquely generated filename, which you parse with regular expressions at the end to generate your SQL statement. You will need to experiment with addslashes(), and other protection mechanisms such as htmlentities().
    [/quote]
    That's really a bad idea. If querying the database multiple times takes too much system load, then this would take even more. I'm not sure about PHP, but I know that in ASP you can use Sessions, which are like cookies, only server-side. These don't create txt files or anything like that. I've not looked into this for PHP.

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>
    Why not just use a simple phpform to add the information of each page. The submition would bring up the next page with the use of
    "include("http://www.somthing.com/somthing.html".
    Am I missing somthing? I do this myself?
    [/quote]
    What? Maybe if you restated it I could understand better.

    I still don't know what the best solution would be.
  16. #9
  17. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    23
    Rep Power
    0
    Unfortunately I am using PHP 3.0. I can't upgrade because there is no compiled binary for php 4 that includes the mssql library. Also, it isn't that I can't have anything kept server side, but I can't have anything in the database, because the database is monitored and once something is put into the database it is printed (by a network printer) automatticaly. This is my logic for only having one database submission.

    ------------------
    Aristotle concluded that those who admit their stupidity are truly wise.
    -
    Gil Hildebrand Jr
    4atcost.com Senior Web Developer
  18. #10
  19. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    61
    Now that I look more closely at the request, I see that server load is an issue (I was thinking more of possible orphaned data), and yes, you are right, JonLed, a serer-side text file would create some server load. Sessions, however, do use cookies, but only for an identifier, to point to server-side stored data (which, in a sense is the same thing I am talking about, but hopefully more optimized). The only drawback is they depend on cookies.

    The real question to ask yourself, Gil, is what should your database layout look like?Even using multiple forms, there is no reason any piece of data has to be entered more than once. In a true normalized relational database, you might have many tables related to one customer's data, for example, so each page of your form could store data that goes to one table, related by customer id. I'm sure you already know this, but maybe you should revisit your design choices.

    The only issue I see is the fact that your network printer spits out every database INSERT, making possible nonsense out of any one user's data if it is spread out over multiple table inserts. Is there any chance the printer can be set up in a more sophisticated way, to only output all the related inserts after completion?
  20. #11
  21. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    23
    Rep Power
    0
    I wrote a Visual Basic program to check my database every 5 minutes to print out new records in the database. But if I inputed information into the database in several stages, some of a customer's information might now get printed because he/she is in the middle of putting in their data. Here is what my queries look like.

    Select * FROM myTable WHERE Printed='0'
    Update myTable SET Printed='1' WHERE ID='$row1[0]'

    Basically that's what it looks like. If I could put things in different tables, that would work. I suppose what I could do is when forms are complete I could set Printed='1' and then set my select statement to Printed='1' and my update statement into Printed='2'. Heh I guess that's my solution huh? Sounsd cool to me, what do you guys think?

    ------------------
    Aristotle concluded that those who admit their stupidity are truly wise.
    -
    Gil Hildebrand Jr
    4atcost.com Senior Web Developer
  22. #12
  23. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    Have a temp table on the DB, a mirror of the real one after generating a unique ID, using uniqueid()?, fill up that record a page at a time.

    I take JonLed's point but 1 query per page will not hurt that much! and as you only need to add to the DB once per page, the user will not notice, when the form is complete transfer the record from the temp table to the 'real' one.

    As a bonus store the unique id via a cookie on the users machine and enable them to contine from where they left off in the case of a disconnection/call of nature/whatever.

    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL
  24. #13
  25. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    23
    Rep Power
    0
    Good ideas firepages, especially the cookie thing. I'll get to work on this tomorrow and see what I can do..

    ------------------
    Aristotle concluded that those who admit their stupidity are truly wise.
    -
    Gil Hildebrand Jr
    4atcost.com Senior Web Developer
  26. #14
  27. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    15
    Rep Power
    0
    When you try to send all the information through the forms with variables, say
    http://www.company.com/forms.php3?name=DiPesa

    you can run into trouble with MSIE browsers. I recently ran into problems when the address became longer than 2k and a few bits. I use MSIE5. I had to update my database with Netscape which didn't have that problem, but maybe its address space is limited as well. And working with such a lot of fields in your forms it is worth investigating.

    Ciao,
    Di Pesa

Similar Threads

  1. LIST/MENU form element with multiple selection
    By acos in forum PHP Development
    Replies: 2
    Last Post: February 17th, 2004, 03:54 PM
  2. Multiple emails in form submission
    By LBeans in forum ASP Programming
    Replies: 1
    Last Post: February 3rd, 2004, 07:18 PM
  3. Replies: 2
    Last Post: January 28th, 2004, 07:07 AM
  4. Inserting from form to multiple tables
    By barth in forum MySQL Help
    Replies: 0
    Last Post: January 25th, 2004, 09:27 AM
  5. Multiple form actions
    By camcim in forum HTML Programming
    Replies: 1
    Last Post: January 11th, 2004, 03:14 AM

IMN logo majestic logo threadwatch logo seochat tools logo