469,286 Members | 2,522 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,286 developers. It's quick & easy.

Transferring variables between seperate hosts

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



Jul 19 '05 #1
10 3478
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



Jul 19 '05 #2
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
:)
Jul 19 '05 #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?


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
Jul 19 '05 #4
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" <no*******@fakoaddresso.como> wrote in message
news:MJ*******************@fe2.news.blueyonder.co. uk...
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


Jul 19 '05 #5
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" <sa*********@nospam-saunalahti.fi> wrote in message
news:aA*****************@reader1.news.jippii.net.. .
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




Jul 19 '05 #6

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


Jul 19 '05 #7
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" <bu**@inhell.com> wrote in message
news:mL********************@comcast.com...
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" <no*******@fakoaddresso.como> wrote in message
news:MJ*******************@fe2.news.blueyonder.co. uk...
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



Jul 19 '05 #8

"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
Jul 19 '05 #9
>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
Jul 19 '05 #10
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
Jul 19 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Mark | last post: by
3 posts views Thread by Abby | last post: by
42 posts views Thread by Dooglo | last post: by
15 posts views Thread by http://www.visual-basic-data-mining.net/forum | last post: by
4 posts views Thread by Marc E | last post: by
2 posts views Thread by garther | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.