posting variables from forms

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

    #1

    posting variables from forms

    With a form, I have two buttons.

    One of them says:
    - pay here

    The other says
    - pay somewhere else

    Now, can I change the location to which the variables from the Form are
    posted, depending on the button that they click? or am I always restricted
    to the location specified in the action (e.g. <form method="post"
    action="mynewpa ge.php">)

    TIA

    - Nicolaas


  • Ian Collins

    #2
    Re: posting variables from forms

    windandwaves wrote:[color=blue]
    > With a form, I have two buttons.
    >
    > One of them says:
    > - pay here
    >
    > The other says
    > - pay somewhere else
    >
    > Now, can I change the location to which the variables from the Form are
    > posted, depending on the button that they click? or am I always restricted
    > to the location specified in the action (e.g. <form method="post"
    > action="mynewpa ge.php">)
    >[/color]
    Not without a little bit of JavaScript on the page to implement an
    onclick handler for the button.

    --
    Ian Collins.

    Comment

    • Geoff Berrow

      #3
      Re: posting variables from forms

      Message-ID: <1137637413.681 943@drone2-svc-skyt.qsi.net.nz > from Ian
      Collins contained the following:
      [color=blue][color=green]
      >> Now, can I change the location to which the variables from the Form are
      >> posted, depending on the button that they click? or am I always restricted
      >> to the location specified in the action (e.g. <form method="post"
      >> action="mynewpa ge.php">)
      >>[/color]
      >Not without a little bit of JavaScript on the page to implement an
      >onclick handler for the button.[/color]

      Yuck!

      Why not put both methods in mynewpage.php and choose which one to use
      depending on which button is pressed?

      --
      Geoff Berrow (put thecat out to email)
      It's only Usenet, no one dies.
      My opinions, not the committee's, mine.
      Simple RFDs http://www.ckdog.co.uk/rfdmaker/

      Comment

      • Al

        #4
        Re: posting variables from forms

        > Why not put both methods in mynewpage.php and choose which one to use[color=blue]
        > depending on which button is pressed?[/color]

        Somewhere else might be a different site.

        Having said that, if "somewhere else" can take GETs rather than POSTs,
        you can direct all form traffic to one php file and see which submit
        button name/value pair is activated and then either run the script if
        it's "here" or do a header("Locatio n: ") if it's the "somewhere else"
        one... But that IS a little odd, and the javascript method is a little
        smoother.

        Comment

        • windandwaves

          #5
          Re: posting variables from forms

          Al wrote:[color=blue][color=green]
          >> Why not put both methods in mynewpage.php and choose which one to use
          >> depending on which button is pressed?[/color]
          >
          > Somewhere else might be a different site.
          >
          > Having said that, if "somewhere else" can take GETs rather than POSTs,
          > you can direct all form traffic to one php file and see which submit
          > button name/value pair is activated and then either run the script if
          > it's "here" or do a header("Locatio n: ") if it's the "somewhere else"
          > one... But that IS a little odd, and the javascript method is a little
          > smoother.[/color]

          Yes, it is funny. Because it seems to make sense that depending on the
          choices from the user the data may have to go to site A or site B. Doing
          the header function means that you loose the posted variables as posts so
          that you have to post them again. Can you do something like this:
          header(post-type, $_POST), basically directly reposting all posted variables
          to a new location?

          HTMS (hope that makes sense)

          - Nicolaas


          Comment

          • Al

            #6
            Re: posting variables from forms


            windandwaves wrote:[color=blue]
            > Doing
            > the header function means that you loose the posted variables as posts so
            > that you have to post them again. Can you do something like this:
            > header(post-type, $_POST), basically directly reposting all posted variables
            > to a new location?[/color]

            Well yes, it loses the informaiton as POSTs but you can recreate them
            as GETs and send them on their way in a header("Locatio n: ");

            But if you want to resend as POSTs I think it's mildly impossible. I'm
            pretty sure you can't do it your way. The header() command just adds
            stuff the to header being sent back to the user, rather than the header
            of the redirected request, unfortunately :)

            I think the javascript way seems to be your only chance, and it's not
            particularly invasive. Plus if people have javascript disabled then you
            can default to my POST -> GET code and at least TRY to fulfil the silly
            non-javascript-user's request :)

            So yeah, employ both methods?

            Comment

            • Pedro Graca

              #7
              Re: posting variables from forms

              windandwaves wrote:[color=blue]
              > Can you do something like this:
              > header(post-type, $_POST), basically directly reposting all posted variables
              > to a new location?[/color]

              Have a look at cURL <http://www.php.net/curl>.

              --
              If you're posting through Google read <http://cfaj.freeshell. org/google>

              Comment

              • Jim Michaels

                #8
                Re: posting variables from forms

                some people don't have JavaScript - some Accessible machines for the
                disabled, for instance.
                I found this out when reading a book on making sites accessible.

                "Al" <alexrussell101 @gmail.com> wrote in message
                news:1137798357 .677856.289200@ g44g2000cwa.goo glegroups.com.. .[color=blue]
                >
                > windandwaves wrote:[color=green]
                >> Doing
                >> the header function means that you loose the posted variables as posts so
                >> that you have to post them again. Can you do something like this:
                >> header(post-type, $_POST), basically directly reposting all posted
                >> variables
                >> to a new location?[/color]
                >
                > Well yes, it loses the informaiton as POSTs but you can recreate them
                > as GETs and send them on their way in a header("Locatio n: ");
                >
                > But if you want to resend as POSTs I think it's mildly impossible. I'm
                > pretty sure you can't do it your way. The header() command just adds
                > stuff the to header being sent back to the user, rather than the header
                > of the redirected request, unfortunately :)
                >
                > I think the javascript way seems to be your only chance, and it's not
                > particularly invasive. Plus if people have javascript disabled then you
                > can default to my POST -> GET code and at least TRY to fulfil the silly
                > non-javascript-user's request :)
                >
                > So yeah, employ both methods?
                >[/color]


                Comment

                • Al

                  #9
                  Re: posting variables from forms

                  Jim Michaels wrote:[color=blue]
                  > some people don't have JavaScript - some Accessible machines for the
                  > disabled, for instance.[/color]

                  Well yes, my smiley was to show I was only joking. But if you saw, I
                  did say that both methods should be employed and that the default
                  behaviour should be the nicer-working JavaScript one.

                  Comment

                  Working...