473,795 Members | 3,481 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving values from the URL

mehj123
55 New Member
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 1708
KevinADC
4,059 Recognized Expert Specialist
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 New Member
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 Recognized Expert Specialist
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 New Member
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
2017
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. Any suggestions please?
13
3959
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 MSXML object then load the XML with a simple objXML.Load(Request). This would give me the XML stream, which I could then manipulate. However, using System.Xml, this is not possible - not that I have found, anyway. The InfoPath documentation...
3
2544
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 controls are not present nor their valves in Request.Form.AllKeys.
0
2073
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 from database to a VB.net app, they retrieve the database fields as a record set eg. "select name, suburb from myTable"
1
1539
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 incrementing/decrementing the vaules in the form. So my website consists of forms... Each form has a number of columns and rows. I am generating each page using a php script and some templates. Because the exact layout of each page can change based on customer...
0
1612
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 enum defined (DotNet v2) as public enum velocityUom { ms = 21,
10
3701
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
5857
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 ID="FldType_add" Runat="server" DataSource='< %#GetFieldType()%>' DataValueField="Type" DataTextField="Type" /> Oce the page is loaded all the values are added to the dropdown list. But when I thought of getting the selected value from the...
15
3537
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 AS IDENTITY ( START WITH 1
5
1981
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 data adaptor.fill or datareader to retrieve the data it takes over 24 seconds. public System.Data.SqlClient.SqlDataReader List1(int PageIndex, int PageSize, string ItemName, string UserIDs, DateTime DateStart, DateTime DateEnd, int status,...
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10437
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10164
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.