I have written some cgi scripts and I need to pass the user id and password between them.. There is a Login page which passes the user name and password to another cgi script through the url which in turn encrypts it and passes it to the next cgi script (again through url). The third cgi script is also able to retrieve the values (using the param method), it adds another variable to the url and passes to the next cgi script..
The strange thing is that in this last cgi, the url has all the values namely the user id, password and the third variable, but I can retrieve only the third variable in the cgi script.. Whatever I do, I cant get the user id and password. I tried printing the url using the query_string, but it also prints something like this
r=42.2, while I can see that the actual url is
Expand|Select|Wrap|Line Numbers
- http://xyz/fourth.cgi?r=42.2&f1=abc&f2=xxx
I am posting here only the third and fourt cgi..
Third.cgi
Expand|Select|Wrap|Line Numbers
- use strict;
- use warnings;
- use CGI qw/:standard/;
- print "Content-type:text/html\n\n";
- my $g_userid = param('field1');
- my $g_pwd = param('field2');
- print $g_userid; # its printing the values correctly
- print $g_pwd;
- print "
- <HTML>
- <HEAD>
- <script language='javascript'>
- function submit_form()
- {
- var r = \"42.2\";
- var user = \"$g_userid\";
- var pwd = \"$g_pwd\";
- alert(user);
- alert(pwd); document.myform.action=document.myform.action+'?r='+r+'&f1='+user+'&f2='+pwd;
- var action = document.myform.action;
- alert(action);
- document.myform.submit();
- }
- </script>
- </HEAD>
- <BODY>
- <FORM ACTION=\"../xyz/fourth.cgi\" name=\"myform\" id=\"MyForm\" method=\"post\">
- print "<input type='button' onclick='javascript:submit_form()' value='Click here\s'>
- </FORM>
- </BODY>
- </HTML>";
- exit(0);
Expand|Select|Wrap|Line Numbers
- use strict;
- use warnings;
- use CGI qw/:standard/;
- print "Content-type:text/html\n\n";
- my $g_r=param('r');
- my $g_usid = param('f1');
- my $g_pd = param('f2');
- print $g_r; # this gets printed
- print $g_usid; # no value for this
- print $g_pd;#no value for this
- my $string = query_string;
- print $string; # only the string r=42.2 gets printed
Thanks
Mehj