Transferring variables between seperate hosts

M

Mark

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
 
S

Sauli Karhu

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
 
M

Michael Austin

Mark said:
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 :)
 
J

Joe Smith

Mark said:
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
 
Z

ZafT

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
 
M

Mark

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
 
M

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

Mark

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
 
M

Mark

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
 
S

Skeleton Man

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
 
J

Joe Smith

Mark said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,775
Messages
2,569,601
Members
45,182
Latest member
BettinaPol

Latest Threads

Top