Storing variables in forms and insert to database

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Venus

    Storing variables in forms and insert to database

    Hi all,

    Newbie here!!

    I have 4 forms(A,B,C,D) and a thank you page for my questionnaire.
    People will be redirected to B or C depending on the last question's
    answer. B or C will redirect to D after B or C is finished. D then
    goes to the thank you page.

    I want to get all the answers from A,B/C,D first and then insert all
    the answers into the database instead of getting each form's answers
    and update the database each time when people click the continue/sumit
    button on each page.

    The problem is now I'm using 'import_request _variables' to get the
    answers from A. It successfully brings all the answers to B/C (I tried
    it by using echo), but when I try to get A's answers in D/the thank
    you page. It doesn't work (tho I tried to use
    'import_request _variables' to get A's answers in D/thank you page ).

    So, I would like to know if there's any way to get the answers from A
    to D/thank you page through B/C?

    Hope the question is not confusing....
    Thank you for everyone who answers my question!!

    Venus
  • Pedro Graca

    #2
    Re: Storing variables in forms and insert to database

    Venus wrote:[color=blue]
    > Hi all,
    >
    > Newbie here!![/color]

    Welcome! enjoy :)
    [color=blue]
    > I have 4 forms(A,B,C,D) and a thank you page for my questionnaire.
    > People will be redirected to B or C depending on the last question's
    > answer. B or C will redirect to D after B or C is finished. D then
    > goes to the thank you page.
    >
    > I want to get all the answers from A,B/C,D first and then insert all
    > the answers into the database instead of getting each form's answers
    > and update the database each time when people click the continue/sumit
    > button on each page.
    >
    > The problem is now I'm using 'import_request _variables' to get the
    > answers from A. It successfully brings all the answers to B/C (I tried
    > it by using echo), but when I try to get A's answers in D/the thank
    > you page. It doesn't work (tho I tried to use
    > 'import_request _variables' to get A's answers in D/thank you page ).[/color]

    Hmmm ... so it seems you're not redirecting from A to B/C and from B/C
    to D after all, or are you?

    If A posts to a redirector script and you do a header() there for B/C
    the data from A doesn't automatically show up in B/C. How did you do
    that?
    [color=blue]
    > So, I would like to know if there's any way to get the answers from A
    > to D/thank you page through B/C?[/color]

    You have to save A answers inside B/C.

    B/C answers will then include A answers (unchanged)
    D will get B/C answers (including A answers) and pass them all to the
    "thank you" page.


    I'd probably go about that like this (using redirector scripts):

    A: normal form, nothing fancy, action to redirector
    the redirector will get A answers and pass them on to B/C the way
    you are already doing it.
    B/C: normal form, action to Dredirector
    The form will have a hidden field with the A answers serialized.
    The Dredirector will had B/C data to the serialized data and put
    that into a hidden field in the D form
    D: normal form, action to "thank you" page
    "thank you" page gets the D data, which you can unserialize to get
    the full A, B/C, D data

    Generates a storable representation of a value

    PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.



    HTH

    --
    USENET would be a better place if everybody read: : mail address :
    http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
    http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
    http://www.expita.com/nomime.html : to 10K bytes :

    Comment

    • Tom Thackrey

      #3
      Re: Storing variables in forms and insert to database


      On 31-Mar-2004, freeforask@yaho o.com.hk (Venus) wrote:
      [color=blue]
      > I have 4 forms(A,B,C,D) and a thank you page for my questionnaire.
      > People will be redirected to B or C depending on the last question's
      > answer. B or C will redirect to D after B or C is finished. D then
      > goes to the thank you page.
      >
      > I want to get all the answers from A,B/C,D first and then insert all
      > the answers into the database instead of getting each form's answers
      > and update the database each time when people click the continue/sumit
      > button on each page.
      >
      > The problem is now I'm using 'import_request _variables' to get the
      > answers from A. It successfully brings all the answers to B/C (I tried
      > it by using echo), but when I try to get A's answers in D/the thank
      > you page. It doesn't work (tho I tried to use
      > 'import_request _variables' to get A's answers in D/thank you page ).
      >
      > So, I would like to know if there's any way to get the answers from A
      > to D/thank you page through B/C?[/color]

      You have a couple of choices:

      1) You can start a session and store the values in $_SESSION
      2) You can put the values from A into B and C as hidden fields ( <input
      type=hidden ... )


      --
      Tom Thackrey

      tom (at) creative (dash) light (dot) com
      do NOT send email to jamesbutler@wil lglen.net (it's reserved for spammers)

      Comment

      Working...