473,396 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Retrieving values from the URL

mehj123
55
Hi...
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
  1. http://xyz/fourth.cgi?r=42.2&f1=abc&f2=xxx
where f1, f2 are user name and password respectively..

I am posting here only the third and fourt cgi..

Third.cgi
Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
  3. use CGI qw/:standard/;
  4. print  "Content-type:text/html\n\n";
  5. my $g_userid = param('field1');
  6. my $g_pwd = param('field2');
  7. print $g_userid; # its printing the values correctly
  8. print $g_pwd;
  9.  
  10. print  "
  11. <HTML>
  12.        <HEAD>
  13.         <script language='javascript'>
  14.         function submit_form()
  15.         {
  16.             var r = \"42.2\";
  17.             var user = \"$g_userid\";
  18.             var pwd = \"$g_pwd\";
  19.             alert(user);
  20.             alert(pwd);                                document.myform.action=document.myform.action+'?r='+r+'&f1='+user+'&f2='+pwd;
  21.                       var action = document.myform.action;
  22.                       alert(action);
  23.                    document.myform.submit();           
  24.         }
  25.     </script>
  26.     </HEAD>
  27.     <BODY>
  28.     <FORM ACTION=\"../xyz/fourth.cgi\" name=\"myform\" id=\"MyForm\" method=\"post\">
  29.   print "<input type='button' onclick='javascript:submit_form()' value='Click here\s'>
  30.     </FORM>
  31.     </BODY>
  32. </HTML>";
  33. exit(0);
Fourth.cgi

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
  3. use CGI qw/:standard/;
  4. print  "Content-type:text/html\n\n";
  5. my $g_r=param('r');
  6. my $g_usid = param('f1');
  7. my $g_pd = param('f2');
  8.  
  9. print $g_r; # this gets printed
  10. print $g_usid; # no value for this
  11. print $g_pd;#no value for this
  12. my $string = query_string;
  13. print $string; # only the string r=42.2 gets printed
  14.  
Is there anything wrong? Why am I able to retrieve only one value from the url? Please help...(Sorry for the long post but I am stuck with this for 2 days :( )

Thanks
Mehj
Mar 12 '08 #1
4 1688
KevinADC
4,059 Expert 2GB
It looks like you are mixing GET (in the javascript) and POST data in Third.cgi. Normally that is not something you want to do. Pick which method you want to use, GET or POST and stick with it.
Mar 12 '08 #2
mehj123
55
It looks like you are mixing GET (in the javascript) and POST data in Third.cgi. Normally that is not something you want to do. Pick which method you want to use, GET or POST and stick with it.
Thanks for the reply KevinADC.. I modified my scripts so that all the method are "Get". But still no change in what output I get. The strange fact is that I am able to get the third variable and ,as I said above also, the entire url is correct.. I dont know why it is not getting the values into the script..
Mar 12 '08 #3
KevinADC
4,059 Expert 2GB
This is the way I would do it if I were going to use javasacript:

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
  3. use CGI qw/:standard/;
  4. print  "Content-type:text/html\n\n";
  5. my $g_userid = 'userid';
  6. my $g_pwd = 'userpassword';
  7. print $g_userid; # its printing the values correctly
  8. print $g_pwd;
  9.  
  10. print  qq{
  11. <HTML>
  12.        <HEAD>
  13.         <script language='javascript'>
  14.         function submit_form()
  15.         {
  16.             var r = "42.2";
  17.             var user = "$g_userid";
  18.             var pwd = "$g_pwd";
  19.             document.myform.id.value = user;
  20.             document.myform.pwd.value = pwd;
  21.             document.myform.r.value = r;
  22.             document.myform.submit();           
  23.         }
  24.     </script>
  25.     </HEAD>
  26.     <BODY>
  27.     <FORM ACTION="fourth.cgi" name="myform" id="MyForm" method="post">
  28.     <input type=hidden name=id value=''>
  29.     <input type=hidden name=pwd value=''>
  30.     <input type=hidden name=r value=''>
  31.     <input type='button' onclick='javascript:submit_form()' value='Click here'>
  32.     </FORM>
  33.     </BODY>
  34. </HTML>};
  35. exit(0);
  36.  
Mar 12 '08 #4
mehj123
55
This is the way I would do it if I were going to use javasacript:

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
  3. use CGI qw/:standard/;
  4. print  "Content-type:text/html\n\n";
  5. my $g_userid = 'userid';
  6. my $g_pwd = 'userpassword';
  7. print $g_userid; # its printing the values correctly
  8. print $g_pwd;
  9.  
  10. print  qq{
  11. <HTML>
  12.        <HEAD>
  13.         <script language='javascript'>
  14.         function submit_form()
  15.         {
  16.             var r = "42.2";
  17.             var user = "$g_userid";
  18.             var pwd = "$g_pwd";
  19.             document.myform.id.value = user;
  20.             document.myform.pwd.value = pwd;
  21.             document.myform.r.value = r;
  22.             document.myform.submit();           
  23.         }
  24.     </script>
  25.     </HEAD>
  26.     <BODY>
  27.     <FORM ACTION="fourth.cgi" name="myform" id="MyForm" method="post">
  28.     <input type=hidden name=id value=''>
  29.     <input type=hidden name=pwd value=''>
  30.     <input type=hidden name=r value=''>
  31.     <input type='button' onclick='javascript:submit_form()' value='Click here'>
  32.     </FORM>
  33.     </BODY>
  34. </HTML>};
  35. exit(0);
  36.  
Thank you so much for taking out the time in helping me.. It is working.. thanks again...:)
Mar 12 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Victor | last post by:
I'm retrieving values from the textboxes that I created dynamically. However I get commas appended to my text values and just a comma wherever the textbox is empty. Dont know what is causing this....
13
by: RHPT | last post by:
I am wanting to capture the XML posted by an InfoPath form with .NET, but I cannot figure out how to capture the XML stream sent back by the InfoPath form. With Classic ASP, I could just create an...
3
by: Dotnet Gruven | last post by:
I've built a WebForm with a Table added dynamically in Page_Load when IsPostBack is false. The table includes a couple of TextBoxes, RadioButtonLists and CheckboxLists. On postback, those...
0
by: Andy | last post by:
Hi All. I'm working for a company that has set out a guideline for retrieving data from a database. Nobody can explain to me the reason for the following. When retrieving a set of records...
1
by: Captain Dondo | last post by:
I am not really experienced in Javascript so bear with me.... I am working with an embedded platform; no mouse, no keyboard. Just up, down, left, right keys and +/- keys for...
0
by: Edward Clements | last post by:
This post is a followup to the thread "retrieving the XmlEnumAttribute values for an Enum" in this same forum earlier this month, since my last query in that thread went unanswered. I have an...
10
by: Girish | last post by:
Hi Everyone, I am passing a form to a php script for further processing. I am able to retrieve the last value set for that given form variable using $variable=$_REQUEST;
6
by: yasodhai | last post by:
Hi, I used a dropdown control which is binded to a datagrid control. I passed the values to the dropdownlist from the database using a function as follows in the aspx itself. <asp:DropDownList...
15
by: gunnar.sigurjonsson | last post by:
I´m having some problem retrieving identity value from my newly inserted row into a view. I have two tables T1 and T2 which I define as following CREATE TABLE T1 ( id BIGINT GENERATED ALWAYS...
5
by: Sanjay Pais | last post by:
I have a table with over 1.3 million rows. I am retrieving only 20 at a time using the with - over clauses In query analyser, the data is retrieved in under a second. When retrieving using the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.