Passing Variables

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

    Passing Variables

    Hi,

    I'm hoping that this can be done.

    I have a form, and upon clicking the submit button it calls another
    PHP script to save the data in a MySQL database. Of course since it
    is a FORM, all the variables are available to the save script. Once
    the data has been saved, I change the location and go to a summary
    page so the customer can see the verification and such.

    The problem is when I go from the save script to the confirmation
    script, all the variables are lost. The save script is a reusable
    script that several scripts use.

    I have a couple of questions. Instead of calling the save script and
    then going to another page, if I make it an include function, will
    that prevent the loss of variables?

    If not, is there another way to do this, since the save script is
    nothing more than PHP code, with no forms or data input....

    Thanks for everyone's help.

    John
  • Michael Fesser

    #2
    Re: Passing Variables

    ..oO(Mtek)
    >I'm hoping that this can be done.
    >
    >I have a form, and upon clicking the submit button it calls another
    >PHP script to save the data in a MySQL database. Of course since it
    >is a FORM, all the variables are available to the save script. Once
    >the data has been saved, I change the location and go to a summary
    >page so the customer can see the verification and such.
    >
    >The problem is when I go from the save script to the confirmation
    >script, all the variables are lost. The save script is a reusable
    >script that several scripts use.
    >
    >I have a couple of questions. Instead of calling the save script and
    >then going to another page, if I make it an include function, will
    >that prevent the loss of variables?
    No. You have to understand how HTTP works. It's a stateless protocol.
    Every request is completely independent from each other. By default
    there's no way to carry variables from one request to another, unless
    you do it yourself.

    Have a look at sessions to store your data and keep it available across
    multiple requests.

    Micha

    Comment

    Working...