SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Bedford, UK
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    2 forms 1 database table - question!

    Sorry, I'm becoming a familiar face to this forum now. Hate to keep bothering, but I am a total n00b!.

    Ok so I have a financial website which has a very detailed (over 100 form fields) application form on it.

    What I am struggling with at the moment is the following:

    I enter my email address and a password on page 1 (for retrieval purposes). This then redirects to the first of four form pages. On the first page (personal details) the form data gets inserted intoa table (secure_loan), they then get redirected to the second page.

    My question is (for design purposes):

    Is it possible to then update the same table (as the first page) with the form data from the second page, or would it be far easier to have a seperate table, and for the retrieval (admin pages) just have sql statements linking tables).

    I am very familiar with Oracle, but not so with MySQL. So I have a loan_id column in the first table, how do I link that to the loan_id on the second table. Do I have to manually create a foreign key or something?

    Sorry, lots of questions, but any advice would be appreciated.

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    How much is a train ticket to Bedford?!

    one thing that I learnt is not to insert data into the database until it has been checked and checked again. What I would do if I were you is to store all inputted data into session variables and print them out on a preview/ confirm page. Then once they have checked it and submitted, insert it into your table and destroy the session.

    You can update the first table ( to answer your first question) by using the last insert id or max id.

    SpikeZ
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Bedford, UK
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello again SpikeZ.

    I told you it wouldn' t be long! lol

    I actually managed to code the next page all by myself, and got it working and updating the database etc... - so proud! lol

    I like your idea about using session varibales, but I have a save and exit button on each page so the user can come back and complete their application later.

    I am fairly SQL savvy so I'm not worried about the scripts for retrieving the data once its in the database, but I just can't get my head around how the second table can know which line it corresponds withh in the first table

    Code:
     secure_loan.loan_id = secure_loan1.loan_id
    How do I get these numbers to mach up?

    I hope I explained it right.

    And by the way its about a 3 hour drive to Bedford (30+ by train), and I have a lovely spare room with a computer in it!!

  4. #4
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Bedford, UK
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Think I'm gonna create 4 tables, and give each of them a foreign key pointing to the loan_id column of the first table.

    However, if I do that, how can I pass this value across the different pages?

    Examples would be great!

  5. #5
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Bedford, UK
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    bump***

  6. #6
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could store them either in the URL and retrieve them using $_GET or you could store them in a session.

    I would go for the session method!

  7. #7
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Bedford, UK
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok so I will need to have a

    PHP Code:
    $_SESSION['foreignkey'] = $foreignkey
    But how do I specify a value for 'foreignkey'?


Bookmarks

Posting Permissions

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