[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 152
  • Last Modified:

Read values from a GET command

I have an HTML page which calls another using a FORM GET command. When the second one called I see the '?' and values after the URL string. How can I read those values?
0
jc31415
Asked:
jc31415
1 Solution
 
KennyIT Application ExecutiveCommented:
If you can use PERL, then this code will work :

#!/usr/bin/perl

#
# To handle input from forms / URL
#


#Putting the Query_string into a variable
      if ($ENV{'REQUEST_METHOD'} eq POST)
            {
            $DataLength=$ENV{'CONTENT_LENGTH'};
            read (STDIN, $QueryString, $DataLength);
            }
      else
            {
            $QueryString = $ENV{'QUERY_STRING'};
            }

#Splitting the pairs and putting them in a list
      @NameValuePairs = split (/&/, $QueryString);

#Preparing for HTML stuff

      print "Content-type: text/html","\n\n";      # MIME header

      print "<HTML>","\n";
      print "<HEAD>","\n";
      print "<TITLE>","Parameters sent in","</TITLE>","\n";
      print "</HEAD>","\n\n";
      print "<BODY>","\n\n";
#Separating the pairs and displaying them on screen.

      $n = 0;
      foreach $NameValue (@NameValuePairs)
      {
            ($Name, $Value) = split (/=/, $NameValue);
            $Value =~ tr/+/ /;
            $Value =~ s/%([\dA-Fa-f][\dA-Fa-f])/ pack ("C", hex ($1))/eg;

            print "Variable=$Name, Value=$Value <BR>\n";
            $MyVarList[$n]=$Name;
            $MyValList[$n]=$Value;
        $n++;
      }

      print "</BODY>","\n\n";
      print "</HTML>","\n\n";
0
 
slokCommented:
normally, these values are sent to a CGI programs or some form of
prorgrams/scripts on the web server

you need to write some program/script (CGI) to handle it.

You can use any language to implement the CGI or handle the web
request.

It can be Perl..., TCL, Java Servlets, ASP, Cold Fusion...

hope this helps
0
 
slokCommented:
normally, these values are sent to a CGI programs or some form of
prorgrams/scripts on the web server

you need to write some program/script (CGI) to handle it.

You can use any language to implement the CGI or handle the web
request.

It can be Perl..., TCL, Java Servlets, ASP, Cold Fusion...

hope this helps
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
slokCommented:
sorry submitted 2 times... meant to post comment only.
0
 
jbirkCommented:
If this is strictly HTML, you can grab these values with javascript.

The variable location.search contains the 'search' string in the url which is everything including and after the '?'. (excluding a hash if one is provided).

It's pretty simple.  If you need help to implement it with something specific, I can help.

-Josh
0
 
xabiCommented:
You must use this in javascript:

<script language="javascript">
<!--
var info = window.location.search.substring(1);
//-->
</script>

this will give you all the info before the ? of the URL, now you only need to split it with "&" to get the vars and split each other with "=" to get the name and the value.

xabi
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now