Gossamer Forum
Home : General : Perl Programming :

passing variables to script on different server

Quote Reply
passing variables to script on different server
This might not be able to be done, but thought I'd see if anyone had any ideas. I'm going to run GMail and when people sign up they will be able to get a free or premium account. What I want to do is when they sign up, if it's for a premium account do all the regular processing that GMail would normally do to set up the account. But, since I'm running multiple domains, my secure server certificate is only good for one of them. So I want to take a few of the variables used when signing up (users' name, login, domain, password) and send that off to a page on the secure server, actually, a script on the secure server so that they can enter their credit card info there and submit. I'd rather not pass the variables in the url string because I am passing the password over to the other script, and the url would end up in the history file for the browser which isn't too secure. I want to make it easy for the user and they will have a username/password for the secure payment process which I need to have matched up with their login name and password so when the results come back, I know which account to set up the additional premium features for. Another option I thought of is to just pass the account id in the string and then do a select on the db for that account. But while I could add a referrer check for security, that's probably a bit to easy to spoof, so I 'm not happy with the security level there. I'm not sure yet if the two domains will be on the same physical box or not yet, but they will certainly be on the same network.

Anyone have any ideas?
Quote Reply
Re: [JerryP] passing variables to script on different server In reply to
You could try the following:

1) Add a redirection statement in your signup script, like the following:

Quote:

print $in->redirect("https://www.something.com/cgibin/gm/something.cgi?username=$username&password=$password&domain=$domain") and return


2) Then in your other subscription script, you'll need to check for these parameters, like the following:

Quote:

if (($IN->param('username') and ($IN->param('password') and ($IN->param('domain')) {
&FORMSUBCALL;
}
else {
&FORMERRORSUBCALL;
}


You can replace the latter sub call with another redirection back to your main suscription form to ensure that the user has passed the correct parameters.

Hope this helps.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [AnthroRules] passing variables to script on different server In reply to
I appreciate the suggestion, but as I mentioned, I wanted to avoid passing the parameters in the URL for security reasons, since the password is one of those parameters. And wouldn't an $in->redirect statement print that full URL which gets tracked in cache, the history file, etc...

Quote Reply
Re: [JerryP] passing variables to script on different server In reply to
Why not take advantage of

FORM METHOD="post"

?

- wil
Quote Reply
Re: [Wil] passing variables to script on different server In reply to
The post would get it to the first script, but how would I get the first script to then do a post to a second on a different server? I've never seen a script do a post to another script. Would I have to use javascript or something?

Another idea I came up with last night is I think going to do the trick. I'm going to use the $in->redirect method, but first I'll create a session variable in the first script to pass to the second one, then the second script will use that to get the data out of the database, and immediately delete the session id, so it's only there for a few seconds. And if they want to pay later, since there won't be a session id anymore, when they go to pay, they'll have to use their login info even thoug the account won't be activated yet.
Quote Reply
Re: [JerryP] passing variables to script on different server In reply to
Why send it to one server just to be bounced to another? Why not just send it directly to the destination server? Would save you a hell of a lot of bother!

Cheers

- wil
Quote Reply
Re: [Wil] passing variables to script on different server In reply to
Because I have the GMail code installed on the first server (with multiple domains and where it still has to do some processing of the account to insert the user, etc.) and the "master" domain the secure server runs on (where the payment part will get processed) is on the second server.
Quote Reply
Re: [JerryP] passing variables to script on different server In reply to
Get them to click something, an image a button, or use Javascript to force the action. Then set up a FORM on the page with all hidden variables inside.

You get the idea; a jump page, like a 'Just one more step => ....'

Cheers

- wil
Quote Reply
Re: [JerryP] passing variables to script on different server In reply to
Hi Jerry,

I have the same question as you.

I have to pass the info from one script to another, then in the middle I have to go to another server, do some stuff, get the data back and finish it up,

I also have to avoid passing the parameters in the url. Were you able to find a solution to your problem?


print $data->redirect(-method => 'POST',
-location => 'http://mywebsite/somescript.pl',
-testing => $testing
)

setting the -method has no effect using CGI even though I read that it should work.

The above doesn't transmit the variable of testing to the next script.

I'd appreciate any idea you can provide as this doesn't work


peace.

Kyle
Quote Reply
Re: [klangan] passing variables to script on different server In reply to
Here is a skeleton script that posts to another script (using POST):
Code:
#!/usr/bin/perl
use strict;
use LWP::UserAgent;
use HTTP::Request::Common qw(POST);

my $ua = LWP::UserAgent->new;

my $req = POST 'http://www.domain.com/script.pl',
['key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3' ];
my $res = $ua->request($req);
print $res->as_string;

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [klangan] passing variables to script on different server In reply to
there's an old post... yes, but I didn't do it, I contracted out to one of my programmers to do it for me... not sure exactly what he did, but I believe he modified the db to store the data needed to be passed so it wouldn't be in the url and it works... wish I could be of more help, sorry.
Quote Reply
Re: [yogi] passing variables to script on different server In reply to
Thanks Yogi,

that was a great help, it works great.

peace.