Transferring variables between seperate hosts

Discussion in 'Perl' started by Mark, Jul 22, 2004.

  1. Mark

    Mark Guest

    This may be a dumb question but can you tranfer variables stored in a PHP
    page on one server to a page on a different server via a form POST and be
    able to access those variables on the new page using Perl? From my
    understanding of HTTP I can't see why this should be a problem but it does
    not seem to work at the moment although I am sure it is not a scripting
    error at this stage

    (Any newbie-level explanations welcomed!!)

    Thanks
    Mark
    Mark, Jul 22, 2004
    #1
    1. Advertising

  2. Mark

    Sauli Karhu Guest

    Yes, it's possible. In the form tag of the PHP/HTML page on server1,
    define the action value as URL to the second server, like this:

    <form action="http://server2.com/process.cgi">

    That's it...or did I misunderstand the question?

    -Sauli Karhu

    Mark wrote:
    > This may be a dumb question but can you tranfer variables stored in a PHP
    > page on one server to a page on a different server via a form POST and be
    > able to access those variables on the new page using Perl? From my
    > understanding of HTTP I can't see why this should be a problem but it does
    > not seem to work at the moment although I am sure it is not a scripting
    > error at this stage
    >
    > (Any newbie-level explanations welcomed!!)
    >
    > Thanks
    > Mark
    >
    >
    >
    >
    >
    >
    >
    Sauli Karhu, Jul 22, 2004
    #2
    1. Advertising

  3. Mark wrote:
    > This may be a dumb question but can you tranfer variables stored in a PHP
    > page on one server to a page on a different server via a form POST and be
    > able to access those variables on the new page using Perl? From my
    > understanding of HTTP I can't see why this should be a problem but it does
    > not seem to work at the moment although I am sure it is not a scripting
    > error at this stage
    >
    > (Any newbie-level explanations welcomed!!)
    >
    > Thanks
    > Mark
    >


    The answer to your question is "it depends".

    Can you show us the relevant code snipettes and any error messages being
    produced and a brief description of what you are trying to accomplish. There is
    always more than one way to achieve the same outcome - and being a "newbie",
    you may have picked the most difficult solution :)

    --
    Michael Austin.
    Consultant - Available.
    Donations welcomed. Http://www.firstdbasource.com/donations.html
    :)
    Michael Austin, Jul 22, 2004
    #3
  4. Mark

    Joe Smith Guest

    Mark wrote:

    > This may be a dumb question but can you tranfer variables stored in a PHP
    > page on one server to a page on a different server via a form POST and be
    > able to access those variables on the new page using Perl?


    1) The usual way of sending variable values from a PHP (or even a plain HTML)
    page to the browser is by using a <FORM> tag and several <INPUT> tags.

    2) The browser can respond to the ACTION= part of the <FORM> tag and
    send modified, unmodified, or hidden values to the target server.

    3) CGI programs written in any language can parse input from the POSTed
    form and use the values.

    Get the third step working first. Then it should be trivial to do
    the first step.
    -Joe
    Joe Smith, Jul 22, 2004
    #4
  5. Mark

    ZafT Guest

    If you post some code, we can disect it a bit. I would start by getting a
    simple version working. As someone already suggested, get the parsing in
    perl down first. Then point your php page in the direction of the perl
    script and you should be in business. I would make the first perl script
    just parse and print out the variable just so you know it got there. Heck,
    you can even get the perl script to write more php code for you if you want.
    Fun stuff - maybe sloppy, but fun.

    Shane


    "Mark" <> wrote in message
    news:MJRLc.49862$...
    > This may be a dumb question but can you tranfer variables stored in a PHP
    > page on one server to a page on a different server via a form POST and be
    > able to access those variables on the new page using Perl? From my
    > understanding of HTTP I can't see why this should be a problem but it does
    > not seem to work at the moment although I am sure it is not a scripting
    > error at this stage
    >
    > (Any newbie-level explanations welcomed!!)
    >
    > Thanks
    > Mark
    >
    >
    >
    >
    >
    >
    >
    ZafT, Jul 23, 2004
    #5
  6. Mark

    Mark Guest

    No you didn't misunderstand as that's pretty much how I understand the
    process of HTTP - the POST variables are just stored in the HTTP
    headers in a platform-independant way so it shouldn't really matter.
    I just don't seem to be able to display them in my page using Perl.

    Probably a problem with my Perl code which I just copied
    from an web tutorial!

    Mark

    "Sauli Karhu" <> wrote in message
    news:aASLc.5129$...
    > Yes, it's possible. In the form tag of the PHP/HTML page on server1,
    > define the action value as URL to the second server, like this:
    >
    > <form action="http://server2.com/process.cgi">
    >
    > That's it...or did I misunderstand the question?
    >
    > -Sauli Karhu
    >
    > Mark wrote:
    > > This may be a dumb question but can you tranfer variables stored in a

    PHP
    > > page on one server to a page on a different server via a form POST and

    be
    > > able to access those variables on the new page using Perl? From my
    > > understanding of HTTP I can't see why this should be a problem but it

    does
    > > not seem to work at the moment although I am sure it is not a scripting
    > > error at this stage
    > >
    > > (Any newbie-level explanations welcomed!!)
    > >
    > > Thanks
    > > Mark
    > >
    > >
    > >
    > >
    > >
    > >
    > >

    >
    Mark, Jul 23, 2004
    #6
  7. Mark

    Mark Guest

    "Michael Austin" wrote
    > Mark wrote:
    > > This may be a dumb question but can you tranfer variables stored in a

    PHP
    > > page on one server to a page on a different server via a form POST and

    be
    > > able to access those variables on the new page using Perl? From my
    > > understanding of HTTP I can't see why this should be a problem but it

    does
    > > not seem to work at the moment although I am sure it is not a scripting
    > > error at this stage
    > >
    > > (Any newbie-level explanations welcomed!!)
    > >
    > > Thanks
    > > Mark
    > >

    >
    > The answer to your question is "it depends".
    >
    > Can you show us the relevant code snipettes and any error messages being
    > produced and a brief description of what you are trying to accomplish.

    There is
    > always more than one way to achieve the same outcome - and being a

    "newbie",
    > you may have picked the most difficult solution :)
    >
    > Michael Austin.
    > Consultant - Available.
    > Donations welcomed. Http://www.firstdbasource.com/donations.html
    > :)


    I say "newbie" but I am more a newbie in Perl than PHP. While I am sure I
    understand the process of POST data in HTTP headers (and my forms pass their
    data quite happily between PHP pages) I suspect I am just not using Perl
    correctly to display the variables. So long as I know that there is no
    theoretical reason why it can't be done I will continue working on my Perl
    code.

    I may post a separate question about this in the Perl newsgroup as soem are
    reading this thread in comp.lang.php.

    Thanks
    Mark.
    Mark, Jul 23, 2004
    #7
  8. Mark

    Mark Guest

    Thanks. I suspect my Perl code so I will work on it as you suggest and post
    to comp.lang.perl if I have any more problems. Thansk again.

    Mark

    "ZafT" <> wrote in message
    news:...
    > If you post some code, we can disect it a bit. I would start by getting a
    > simple version working. As someone already suggested, get the parsing in
    > perl down first. Then point your php page in the direction of the perl
    > script and you should be in business. I would make the first perl script
    > just parse and print out the variable just so you know it got there.

    Heck,
    > you can even get the perl script to write more php code for you if you

    want.
    > Fun stuff - maybe sloppy, but fun.
    >
    > Shane
    >
    >
    > "Mark" <> wrote in message
    > news:MJRLc.49862$...
    > > This may be a dumb question but can you tranfer variables stored in a

    PHP
    > > page on one server to a page on a different server via a form POST and

    be
    > > able to access those variables on the new page using Perl? From my
    > > understanding of HTTP I can't see why this should be a problem but it

    does
    > > not seem to work at the moment although I am sure it is not a scripting
    > > error at this stage
    > >
    > > (Any newbie-level explanations welcomed!!)
    > >
    > > Thanks
    > > Mark
    > >
    > >
    > >
    > >
    > >
    > >
    > >

    >
    >
    Mark, Jul 23, 2004
    #8
  9. Mark

    Mark Guest

    "Joe Smith" wrote
    > Mark wrote:
    >
    > > This may be a dumb question but can you tranfer variables stored in a

    PHP
    > > page on one server to a page on a different server via a form POST and

    be
    > > able to access those variables on the new page using Perl?

    >
    > 1) The usual way of sending variable values from a PHP (or even a plain

    HTML)
    > page to the browser is by using a <FORM> tag and several <INPUT> tags.
    >
    > 2) The browser can respond to the ACTION= part of the <FORM> tag and
    > send modified, unmodified, or hidden values to the target server.
    >
    > 3) CGI programs written in any language can parse input from the POSTed
    > form and use the values.
    >
    > Get the third step working first. Then it should be trivial to do
    > the first step.
    > -Joe


    Thanks - will do. I suspect my Perl code so I will work on it as you suggest
    and post to comp.lang.perl if I have any more problems.

    Thanks.

    Mark
    Mark, Jul 23, 2004
    #9
  10. Mark

    Skeleton Man Guest

    >This may be a dumb question but can you tranfer variables stored in a PHP
    >page on one server to a page on a different server via a form POST and be
    >able to access those variables on the new page using Perl? From my
    >understanding of HTTP I can't see why this should be a problem but it does
    >not seem to work at the moment although I am sure it is not a scripting
    >error at this stage


    Post your code so we can see if/where you're going wrong.

    Regards,
    Chris
    Skeleton Man, Jul 23, 2004
    #10
  11. Mark

    Joe Smith Guest

    Mark wrote:

    > you didn't misunderstand as that's pretty much how I understand the
    > process of HTTP - the POST variables are just stored in the HTTP
    > headers in a platform-independant way so it shouldn't really matter.


    The POST variables are stored in the body of the POST, not the headers.

    > I just don't seem to be able to display them in my page using Perl.


    1) Parse the POST body, using CGI.pm or other module that puts the
    field names and values into a perl hash.
    2) Create an HTML response using the data obtained from step 1.

    I'd recommend writing a simple perl CGI that can handle this:
    <form action="/cgi-bin/hello-world.cgi" method="POST">
    <input type="text" name="yourname" value="Enter your name here">
    <input type="hidden" name="private_variable" value="secret">
    </form>

    -Joe
    Joe Smith, Jul 23, 2004
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bla
    Replies:
    0
    Views:
    2,857
  2. Jim Bayers
    Replies:
    7
    Views:
    346
  3. moondaddy
    Replies:
    2
    Views:
    576
    Steven Cheng[MSFT]
    Oct 16, 2006
  4. Hanumant Ganpat

    About transferring session variables...

    Hanumant Ganpat, Feb 9, 2010, in forum: ASP .Net
    Replies:
    3
    Views:
    593
    deveti putnik
    Feb 10, 2010
  5. Bla
    Replies:
    1
    Views:
    206
    Tad McClellan
    Apr 10, 2005
Loading...

Share This Page