Fairly simple logic problem using PHP?

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

    #1

    Fairly simple logic problem using PHP?

    Hi All!

    I wonder if anyone could help me with the underlying logic of a problem I
    have. At the moment my working pages run like so

    ---------------------------------------------------------
    PAGE1: A form which gathers variables and POSTS them on to the next page.

    PAGE2: This page does a few simple calculations based on the variables
    gathered on PAGE1 and echoes the results to screen. It also contains a two
    buttons - one lets you quit and one that allows the results to be URLENCODED
    to PAGE 3

    PAGE3: Takes the URLENCODED results, amalgamates them into one long string
    and MAILS them to me.

    END
    ---------------------------------------------------------


    Now what I would *like* to do is add a small form on PAGE2 that would allow
    people to add their contact details if the echoed results were to their
    liking, before passing the whole lot on to PAGE3 as usual.

    However, I get confused as to how I might be able to both submit this mini
    form and at the same time be able to forward on my previously gathered
    results from the form on PAGE1.

    Does this makes sense? If anyone could help me out here with *anything* at
    all that might help, I would be so grateful...

    Thanks if you can,

    Steve M.



  • Pedro Graca

    #2
    Re: Fairly simple logic problem using PHP?

    Steve wrote:[color=blue]
    > I wonder if anyone could help me with the underlying logic of a problem I
    > have. At the moment my working pages run like so
    >
    > ---------------------------------------------------------
    > PAGE1: A form which gathers variables and POSTS them on to the next page.
    >
    > PAGE2: This page does a few simple calculations based on the variables
    > gathered on PAGE1 and echoes the results to screen. It also contains a two
    > buttons - one lets you quit and one that allows the results to be URLENCODED
    > to PAGE 3
    >
    > PAGE3: Takes the URLENCODED results, amalgamates them into one long string
    > and MAILS them to me.
    >
    > END
    > ---------------------------------------------------------
    >
    >
    > Now what I would *like* to do is add a small form on PAGE2 that would allow
    > people to add their contact details if the echoed results were to their
    > liking, before passing the whole lot on to PAGE3 as usual.
    >
    > However, I get confused as to how I might be able to both submit this mini
    > form and at the same time be able to forward on my previously gathered
    > results from the form on PAGE1.
    >
    > Does this makes sense? If anyone could help me out here with *anything* at
    > all that might help, I would be so grateful...[/color]

    You can pass parameters in the URL for a POSTed form:

    ## page2
    <form method="post" action="page3.p hp?data=$urlenc oded_data">
    <input type="text" name="address">
    <input type="submit">
    </form>

    ## page3
    mail('your_addr ess@example.com ', 'form data with contact details',
    "Someone entered this data:\n\n" .
    "{$_GET['data']}\n\n" .
    "The user details are:\n" .
    " address: {$_POST['address']}");


    --
    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

    • Dennis Biletsky

      #3
      Re: Fairly simple logic problem using PHP?


      "Steve" <luckylucky200@ hotmail.com> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:
      news:40acbe0c$0 $47324$c3e8da3@ news.astraweb.c om...[color=blue]
      > Hi All!
      >[/color]
      [skip][color=blue]
      >
      > However, I get confused as to how I might be able to both submit this mini
      > form and at the same time be able to forward on my previously gathered
      > results from the form on PAGE1.
      >
      > Does this makes sense? If anyone could help me out here with *anything* at
      > all that might help, I would be so grateful...
      >
      > Thanks if you can,
      >
      > Steve M.
      >
      >
      >[/color]
      You can use <input type="hidden" value="your_val ue_from_previou s_form"> in
      your mini form on page2. Thus, you can POST results from form on page1 to
      page3 via form on page2.


      Comment

      • Dennis Biletsky

        #4
        Re: Fairly simple logic problem using PHP?


        "Pedro Graca" <hexkid@hotpop. com>
        [skip][color=blue]
        > You can pass parameters in the URL for a POSTed form:
        >
        > ## page2
        > <form method="post" action="page3.p hp?data=$urlenc oded_data">[/color]

        Method is POST. Are you sure that he can obtain GET data in this case?



        Comment

        • Pedro Graca

          #5
          Re: Fairly simple logic problem using PHP?

          Dennis Biletsky wrote:[color=blue]
          >
          > "Pedro Graca" <hexkid@hotpop. com>
          > [skip][color=green]
          >> You can pass parameters in the URL for a POSTed form:
          >>
          >> ## page2
          >> <form method="post" action="page3.p hp?data=$urlenc oded_data">[/color]
          >
          > Method is POST. Are you sure that he can obtain GET data in this case?[/color]

          Yes.

          <form method="post" action="test.ph p?id=one">
          <input type="text" name="id" value="two">
          <input type="submit">
          </form>



          and on test.php you can do:

          <?php
          echo $_GET['id']; // one
          echo $_POST['id']; // two, if it hasn't been changed
          ?>

          If you use $_REQUEST['id'] it will get "one" or "two" depending on your
          configuration.

          --
          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

          • Dennis Biletsky

            #6
            Re: Fairly simple logic problem using PHP?


            "Pedro Graca" <hexkid@hotpop. com> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:
            news:2h43q5F8oh p0U1@uni-berlin.de...[color=blue]
            > Dennis Biletsky wrote:[color=green]
            > >
            > > "Pedro Graca" <hexkid@hotpop. com>
            > > [skip][color=darkred]
            > >> You can pass parameters in the URL for a POSTed form:
            > >>
            > >> ## page2
            > >> <form method="post" action="page3.p hp?data=$urlenc oded_data">[/color]
            > >
            > > Method is POST. Are you sure that he can obtain GET data in this case?[/color]
            >
            > Yes.
            >
            > <form method="post" action="test.ph p?id=one">
            > <input type="text" name="id" value="two">
            > <input type="submit">
            > </form>
            >
            >
            >
            > and on test.php you can do:
            >
            > <?php
            > echo $_GET['id']; // one
            > echo $_POST['id']; // two, if it hasn't been changed
            > ?>
            >
            > If you use $_REQUEST['id'] it will get "one" or "two" depending on your
            > configuration.
            >[/color]

            It works. Thanks. It is convenient.[color=blue]
            > --
            > 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 :[/color]


            Comment

            • Steve

              #7
              Re: Fairly simple logic problem using PHP?

              > >[color=blue][color=green]
              > > However, I get confused as to how I might be able to both submit this[/color][/color]
              mini[color=blue][color=green]
              > > form and at the same time be able to forward on my previously gathered
              > > results from the form on PAGE1.
              > >
              > > Does this makes sense? If anyone could help me out here with *anything*[/color][/color]
              at[color=blue][color=green]
              > > all that might help, I would be so grateful...[/color]
              >
              > You can pass parameters in the URL for a POSTed form:
              >
              > ## page2
              > <form method="post" action="page3.p hp?data=$urlenc oded_data">
              > <input type="text" name="address">
              > <input type="submit">
              > </form>
              >
              > ## page3
              > mail('your_addr ess@example.com ', 'form data with contact details',
              > "Someone entered this data:\n\n" .
              > "{$_GET['data']}\n\n" .
              > "The user details are:\n" .
              > " address: {$_POST['address']}");[/color]

              Thanks - I'm halfway there, I think. I'm getting my POST data through to the
              next page, but I'm not sure how or if I can use the URLENCODE command within
              the form? Whereas I used to have the data passed on like so:

              echo '<a href="mail.php? radiochoice=', urlencode($radi obutton),
              '&radiomoderntr ad=', urlencode($radi omoderntrad),
              '&radiocoord= ', urlencode($radi ocoord),
              '&radiopacking= ', urlencode($radi opacking),
              '&i1=', urlencode($item 1),
              '&i2=', urlencode($item 2),
              '&i3=', urlencode($item 3),
              '&i4=', urlencode($item 4),
              '&i5=', urlencode($item 5),
              '&i6=', urlencode($item 6), ETC.

              when I try to do a (obviously botched?!) cut and paste job to get the
              following:

              <form name="form1" method="post" action="finalte st.php?stevetes t=",
              urlencode($item 1),' stevetest2=', urlencode($item 2),'">
              <p>

              <input type="text" name="textfield ">
              </p>
              <p>
              <input type="submit" name="submit" value="Submit">
              </p>
              </form>?>

              I get a 'Parse error: parse error, unexpected '<'' - yes, my grasp is syntax
              is pretty crappy, but I'm no programmer - just a GFX guy trying to learn!
              Anyone able to help me mastering this last piece of my jigsaw?

              THANKS!

              Steve


              Comment

              Working...