Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Read values from a GET command

Posted on 2000-02-28
6
146 Views
Last Modified: 2010-04-09
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
Comment
Question by:jc31415
6 Comments
 
LVL 1

Expert Comment

by:zxr250
ID: 2567252
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
 
LVL 3

Expert Comment

by:slok
ID: 2567256
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
 
LVL 3

Expert Comment

by:slok
ID: 2567257
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 3

Expert Comment

by:slok
ID: 2567261
sorry submitted 2 times... meant to post comment only.
0
 
LVL 8

Expert Comment

by:jbirk
ID: 2567691
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
 
LVL 8

Accepted Solution

by:
xabi earned 50 total points
ID: 2567876
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question