Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing variable to another CGI script

Status
Not open for further replies.

N8bak

Technical User
Aug 16, 2004
25
US
Greetings. We are migrating our sites from an existing C based CGI script to a more functional Perl based app. During the transition we need to be able to route the user/customer to one script or the other based on the phone number they input. Both of the CGI scripts are written by third parties and I would like to avoid rewriting them if possible. Ideally I would like to prompt first for the phone# then pass that variable to the appropriate script. I know this can be handled via cookies, but I'm hoping for something more secure. Thanks in advance.

~N8

"Be not afraid of greatness. Some are born great, some achieve greatness, and some have greatness thrust upon `em." - Twelfth Night, II:5
 
There's not much else you can do to make anything "more secure" when passing variables around apart from using SSL.

Instead of using cookies, you can pass a variable to a CGI script through the query string with the GET method or as a form variable with the POST method.

If one CGI script already gets and deals with a form variable like this, and you want that CGI script to be able to pass it to the other... the CGI script would have to write out another form or something with the variable in it (probably with a hidden field), and the form would submit to the other CGI script.

Or, it would take some modification, but the first CGI script could save the variable to a file, and the second CGI script could read from it. This way, the variable can't be tampered with by the user from one CGI to the next.

-------------
Cuvou.com | The NEW Kirsle.net
 
Thanks for the reply Kirsle. I'm thinking it might be easier to set up some sort of conditional statment within the new perl script for the submit button.

If phone# = xyz
then
submit to old CGI script
else
continue with perl CGI

Is it possible to do something like that?

~N8

"Be not afraid of greatness. Some are born great, some achieve greatness, and some have greatness thrust upon `em." - Twelfth Night, II:5
 
I'm not a 100% sure so you might want to ask in the JavaScript forum , but I beleive you can use the 'onsubmit' event to call a function that can alter the 'action' atribute URL of a form.

I guess it would be along the lines of document.getElementById('id_of_form').action='URL_TO_NEW_SCRIPT';

and of course it would already contain the URL_TO_OLD_SCRIPT as the value in the form.

hope the makes sense and points you in the right direction.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Thanks for the reply 1DMF. I'll try to pursue it from that angle.

~N8

"Be not afraid of greatness. Some are born great, some achieve greatness, and some have greatness thrust upon `em." - Twelfth Night, II:5
 
Thanks for the reply Kirsle. I'm thinking it might be easier to set up some sort of conditional statment within the new perl script for the submit button.

If phone# = xyz
then
submit to old CGI script
else
continue with perl CGI

Is it possible to do something like that?

yes, that is possible.

- Kevin, perl coder unexceptional! [wiggle]
 
Thanks for the reply KevinADC. How would you suggest I go about setting up the conditional for the submit button?

~N8

"Be not afraid of greatness. Some are born great, some achieve greatness, and some have greatness thrust upon `em." - Twelfth Night, II:5
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top